• 日常训练


    这是一场爆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

     E题gcd,先看颜色奇数有多少个,奇数大于1就是输出0,否则就是gcd,然后输出的时候交替输出

    #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 C 0.5772156649
    #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-7;
    const int N=2000+10,maxn=500+100,inf=0x3f3f3f;
    
    int color[30];
    inline int gcd(int a,int b)
    {
        return b?gcd(b,a%b):a;
    }
    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        int n,x=0;
        cin>>n;
        for(int i=0;i<n;i++)
        {
            cin>>color[i];
            x=gcd(x,color[i]);
        }
        int s=0;
        for(int i=0; i<n; i++)
            if(color[i]%2==1)
                s++;
        if(s>1)
        {
            cout<<0<<endl;
            for(int i=0; i<n; i++)
                for(int j=1; j<=color[i]; j++)
                    cout<<(char)(i+'a');
            cout<<endl;
            return 0;
        }
        cout<<x<<endl;
        string ans="";
        for(int i=0;i<n;i++)
            for(int j=0;j<color[i]/x/2;j++)
               ans+=(i+'a');
        for(int i=0;i<n;i++)
            if(color[i]/x%2==1)
               ans+=(i+'a');
        for(int i=n-1;i>=0;i--)
            for(int j=0;j<color[i]/x/2;j++)
               ans+=(i+'a');
        for(int i=0;i<x;i++)
        {
            cout<<ans;
            reverse(ans.begin(),ans.end());
        }
        cout<<endl;
        return 0;
    }
    /********************
    2
    2 2
    ********************/
    E
  • 相关阅读:
    Eolink接口管理工具应用
    【内有红包封面】如何简单设计接口测试用例
    IDEA 激活 JRebel教程
    springboot 集成添加 Swagger3 支持
    Kubernetes部署官网Dashboard
    Kubernetes部署第三方Dashboardkuboard
    Kubernetes部署CoreDNS
    项目初始化报 404 Not Found GET https://registry.npmjs.org(转)
    vue项目初始化出现tar ENOENT: no such file or directory错误的解决办法。(转)
    Debian / Ubuntu 系统怎么缩短 shell 路径(转)
  • 原文地址:https://www.cnblogs.com/acjiumeng/p/7219405.html
Copyright © 2020-2023  润新知