Codeforces Round #198 (Div. 2)A,B题解

本文针对 Codeforces Round #198 (Div.2) 的 A 题 The Wall 和 B 题 Maximal Area Quadrilateral 提供了解题思路及代码实现。对于 A 题,通过计算最小公倍数找出符合条件的砖块数量;对于 B 题,则通过枚举对角线的方式,结合叉积求得最大面积。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Codeforces Round #198 (Div. 2)

昨天看到奋斗群的群赛,好奇的去做了一下,

大概花了3个小时Ak,我大概可以退役了吧

那下面来稍微总结一下

A. The Wall

Iahub and his friend Floyd have started painting a wall. Iahub is painting the wall red and Floyd is painting it pink. You can consider the wall being made of a very large number of bricks, numbered 1, 2, 3 and so on.

Iahub has the following scheme of painting: he skips x - 1 consecutive bricks, then he paints the x-th one. That is, he'll paint bricks xxx and so on red. Similarly, Floyd skips y - 1 consecutive bricks, then he paints the y-th one. Hence he'll paint bricks yyy and so on pink.

After painting the wall all day, the boys observed that some bricks are painted both red and pink. Iahub has a lucky number a and Floyd has a lucky number b. Boys wonder how many bricks numbered no less than a and no greater than b are painted both red and pink. This is exactly your task: compute and print the answer to the question.

input
2 3 6 18
output
3
Note

Let's look at the bricks from a to b (a = 6, b = 18). The bricks colored in red are numbered 6, 8, 10, 12, 14, 16, 18. The bricks colored in pink are numbered 6, 9, 12, 15, 18. The bricks colored in both red and pink are numbered with 6, 12 and 18.

一句话题意:给你a,b,n,m,求在[n,m](闭区间)内有多少个数可以同时整除a和b

很显然非常清真的一道A题,题意很明晰,

求出a,b的最小公倍数,然后求出n以内和m以内各有几个,

最后相减,注意因为是闭区间,所以要特判n是否符合

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,n,m;
    scanf("%d%d%d%d",&a,&b,&n,&m);
    int lcs=a/__gcd(a,b)*b,ans1=n/lcs,ans2=m/lcs;
    if (n%lcs==0) ans1--;
    printf("%d",ans2-ans1);
}
View Code

 

B. Maximal Area Quadrilateral

Iahub has drawn a set of n points in the cartesian plane which he calls "special points". A quadrilateral is a simple polygon without self-intersections with four sides (also called edges) and four vertices (also called corners). Please note that a quadrilateral doesn't have to be convex. A special quadrilateral is one which has all four vertices in the set of special points. Given the set of special points, please calculate the maximal area of a special quadrilateral.

input
5
0 0
0 4
4 0
4 4
2 3
output
16.000000
Note

In the test example we can choose first 4 points to be the vertices of the quadrilateral. They form a square by side 4, so the area is 4·4 = 16.

一句话题意:给你n个点,让你选出四个点,使得这四个点组成的四边形面积最大

感觉这道题其实有D题的难度,可参见考试时A掉人数:A>D>C>B>E

首先我们可以把一个四边形分成两个三角形来求

这样那我们可以O(n^2)枚举对角线,然后就可以求出上三角形的最大值和下三角形的最大值

我们就可以得出最大的四边形的面积,

求三角形面积可以用叉积,这样,就可以得到了O(n^3)的了

***如果不会叉积的,极力推荐去学习一下计算几何初步

#include <cstdio>
#include <complex>
#include <algorithm>
using namespace std;
typedef complex<int> xint;
const int inf=1000010000;
xint point[330];
int crs(xint a,xint b){
    return (a.real()*b.imag()-a.imag()*b.real());
}

int main(){
     int n,s=0; scanf("%d",&n);
      for (int i=0,x,y;i<n&&2==scanf("%d %d",&x,&y);++i) 
          point[i]=xint(x,y);
    for (int i=0;i<n;++i)
        for (int j=i+1;j<n;++j){
            int a=inf,b=-inf;
            for (int k=0;k<n;++k){
                  int c=crs(point[k]-point[i],point[j]-point[i]);
                  if(c<0) a=min(a,c); else if(c>0) b=max(b,c);
                  if(a<0&&b>0) s=max(s,b-a);
                }
          }
      printf("%.8lf\n",s/2.0);
}
View Code

转载于:https://www.cnblogs.com/logic-yzf/p/7567452.html

内容概要:该研究通过在黑龙江省某示范村进行24小时实地测试,比较了燃煤炉具与自动/手动进料生物质炉具的污染物排放特征。结果显示,生物质炉具相比燃煤炉具显著降低了PM2.5、CO和SO2的排放(自动进料分别降低41.2%、54.3%、40.0%;手动进料降低35.3%、22.1%、20.0%),但NOx排放未降低甚至有所增加。研究还发现,经济性和便利性是影响生物质炉具推广的重要因素。该研究不仅提供了实际排放数据支持,还通过Python代码详细复现了排放特征比较、减排效果计算和结果可视化,进一步探讨了燃料性质、动态排放特征、碳平衡计算以及政策建议。 适合人群:从事环境科学研究的学者、政府环保部门工作人员、能源政策制定者、关注农村能源转型的社会人士。 使用场景及目标:①评估生物质炉具在农村地区的推广潜力;②为政策制定者提供科学依据,优化补贴政策;③帮助研究人员深入了解生物质炉具的排放特征和技术改进方向;④为企业研发更高效的生物质炉具提供参考。 其他说明:该研究通过大量数据分析和模拟,揭示了生物质炉具在实际应用中的优点和挑战,特别是NOx排放增加的问题。研究还提出了多项具体的技术改进方向和政策建议,如优化进料方式、提高热效率、建设本地颗粒厂等,为生物质炉具的广泛推广提供了可行路径。此外,研究还开发了一个智能政策建议生成系统,可以根据不同地区的特征定制化生成政策建议,为农村能源转型提供了有力支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值