暑假集训cf50练之12

这是一场爆0的比赛。。。。。。

第一题wa了20发,longlong改double再改unsigned long long还是wa,最后判断的时候改成除,边界设为1e19就过了

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

const double g=10.0,eps=1e-12;
const int N=100000+10,maxn=500+100,inf=0x3f3f3f;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<setiosflags(ios::fixed)<<setprecision(0);
    unsigned long long l,r,k,s=1;
    cin>>l>>r>>k;
    bool f=0;
    for(int i=0;;i++)
    {
      //  cout<<s<<endl;
        if(s>=l&&s<=r)
        {
            cout<<s<<" ";
            f=1;
        }
        if(1e19/s<k)break;
        s*=k;
    }
    if(!f)cout<<-1;
    cout<<endl;
    return 0;
}
/*********************
1 1000000000000000000 10
*********************/

A

A题python写超级简单= =

l,r,k=input().strip().split()
s = 1
s = int(s)
l = int(l)
r = int(r)
k = int(k)
f = 0
for i in range(1000):
    if s>=l and s<=r:
        f = 1
        print(s)
    elif s>r:
        break
    s*=k
if f == 0:
    print(-1)

A python版

B正常直接相乘肯定t掉,转化成字符串记录0的个数

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

const double g=10.0,eps=1e-12;
const int N=100000+10,maxn=500+100,inf=0x3f3f3f;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,zero=0;
    cin>>n;
    bool mulzero=0;
    string ans="1";
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(s.size()==1&&s[0]==‘0‘)
        {
            mulzero=1;
            continue;
        }
        bool ok=1;
        for(int j=0;j<s.size();j++)
        {
            if(j==0&&s[0]!=‘1‘)ok=0;
            else if(j!=0&&s[j]!=‘0‘)ok=0;
        }
        if(ok)zero+=(s.size()-1);
        else ans=s;
    }
    if(mulzero)cout<<0<<endl;
    else cout<<ans<<string(zero,‘0‘)<<endl;
    return 0;
}
/*********************

*********************/

B

C计算几何,先扫点记录最大距离,再扫边记录最小距离(先判断点到边能不能直接计算最短距离)

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

const double g=10.0,eps=1e-12;
const int N=100000+10,maxn=500+100,inf=0x3f3f3f;

struct point{
    double x,y;
    point(){}
    point(double _x,double _y):x(_x),y(_y){}
}p[N];
double dis(point p1,point p2)
{
    return sqrt((p2.x-p1.x)*(p2.x-p1.x)+(p2.y-p1.y)*(p2.y-p1.y));
}
double linedis(point p1,point p2,point p3)
{
    double a1=p3.y-p2.y,b1=-(p3.x-p2.x),c1=-p3.x*(p3.y-p2.y)+p3.y*(p3.x-p2.x);
    double a2=p3.x-p2.x,b2=p3.y-p2.y,c2=-p1.x*(p3.x-p2.x)-p1.y*(p3.y-p2.y);
    double x,y;
    if(a1==0&&a2!=0)
    {
        y=-c1/b1,x=(-b2*y-c2)/a2;
    }
    else if(a1!=0&&a2==0)
    {
        y=-c2/b2,x=(-b1*y-c1)/a1;
    }
    else
    {
        x=(b1*c2-b2*c1)/(b2*a1-b1*a2);
        if(b1==0)y=(-a2*x-c2)/b2;
        else y=(-a1*x-c1)/b1;
    }
   /* cout<<a1<<" "<<b1<<" "<<c1<<endl;
    cout<<a2<<" "<<b2<<" "<<c2<<endl;
    cout<<x<<" "<<y<<endl;*/
    point p(x,y);
    if((p2.x<x&&x<p3.x)||(p3.x<x&&x<p2.x))return dis(p,p1);
    if((p2.y<y&&y<p3.y)||(p3.y<y&&y<p2.y))return dis(p,p1);
    return min(dis(p1,p2),dis(p1,p3));
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<setiosflags(ios::fixed)<<setprecision(10);
    int n;
    point o;
    cin>>n>>o.x>>o.y;
    for(int i=0;i<n;i++)
        cin>>p[i].x>>p[i].y;
    p[n]=p[0];
    double minn=1e7,maxx=0;
    for(int i=0;i<n;i++)
    {
        maxx=max(maxx,dis(o,p[i]));
        minn=min(minn,linedis(o,p[i],p[i+1]));
    }
   // cout<<maxx<<" "<<minn<<endl;
    cout<<(maxx-minn)*(maxx+minn)*pi<<endl;
    return 0;
}
/*********************
3 0 0
-1 1
0 3
1 1
3 -3 3
-3 2
5 -5
5 3
*********************/

C

时间: 2024-12-20 01:04:42

暑假集训cf50练之12的相关文章

暑假集训cf50练之10

A水题,判断第一个,后面的全是0 #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include<iomanip> #include<cstdlib> #include<cs

暑假集训cf50练之7

Codeforces Round #409 第一题很水但是wa了一发,因为没考虑K前面是K的情况 #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include<iomanip> #inclu

暑假集训cf50练之19

Codeforces Round #388 (Div. 2) A水,总是忘记输出个数 #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include<iomanip> #include<

暑假集训cf50练之18

Codeforces Round #426 (Div. 2) A,判断向哪边旋转的,枚举过的=  =,感觉我的太复杂了,应该有更简单的方法 #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include&

暑假集训cf50练之15

CodeForces 402A 水题,模拟 #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include<iomanip> #include<cstdlib> #include&

暑假集训cf50练之8

Codeforces Round #400 最近好像总是有点不想打,专题也刷不动,还是坚持这做了一场,虽然打到一半就没打了...(反正通常都只能做出两题) 感觉自己切水题越来越熟练了,然而难题还是不会做.. A题,水,用vector存下来就行了 #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #in

暑假集训cf50练之3

Codeforces Round #349 (Div. 2) 第一题直接算就行了为了追求手速忘了输出yes导致wa了一发... 第二题技巧题,直接sort,然后把最大的和其他的相减就是构成一条直线,为了满足条件就+1 #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdi

暑假集训cf50练之14

Codeforces Round #425 (Div. 2) A超级水,三分钟1a #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include<iomanip> #include<c

暑假集训(2)第五弹 ----- Who&#39;s in the Middle(poj2388)

G - Who's in the Middle Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description FJ is surveying his herd to find the most average cow. He wants to know how much milk this 'median