zoukankan      html  css  js  c++  java
  • Codeforces Goodbye 2018

    比赛传送门

    终于摆脱(pupil)!成为(Specialist)

    元旦(RP++)


    A.New Year and the Christmas Ornament

    没什么好说的,送分题

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    int main(){
        int y,b,r,ans=0;
        cin>>y>>b>>r;
        ans+=min(y,min(b-1,r-2))*3+1+2;
        cout<<ans;
        return 0;
    }
    

    B.New Year and the Treasure Geolocation

    因为每个向量和每个坐标都是一一对应的,而它们又都指向目标地点,所以我们枚举目标地点就好了。
    我们用第一个坐标去试每个向量,找出目标地点,再判断目标地点是否合法,即目标地点对于每一个向量,都有一个坐标对应
    偷懒用(map)

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<map>
    using namespace std;
    map <int,map<int,bool> > q;
    int a[1010],b[1010],xx,yy;
    int main(){
        int n; cin>>n;
        for(int i=1;i<=n;i++){
            int x,y;
            scanf("%d%d",&x,&y);
            if(i==1) xx=x,yy=y;
            q[x][y]=1;
        }
        for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
        for(int i=1;i<=n;i++){
            int ansx=xx+a[i],ansy=yy+b[i];
            bool flag=0;
            for(int j=1;j<=n;j++){
                if(!q[ansx-a[j]][ansy-b[j]]){
                    flag=1; break;
                }
            }
            if(flag) continue;
            else{
                cout<<ansx<<" "<<ansy;
                return 0;
            }
        }
        return 0;
    }
    

    C.New Year and the Sphere Transmission

    虽然我不会证,但我会猜结论啊!

    (10^9)的数据范围,不是(O(sqrt n))就是(O(log n))
    再根据这道题的实际情况,可以猜出(k)只跟(n)的因数有关。
    要快速的算出“快乐值”,可以用等差数列求和公式

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<map>
    #include<cmath>
    #define LL long long
    using namespace std;
    LL read(){
        LL k=0; char c=getchar();
        while(c<'0'||c>'9') c=getchar();
        while(c>='0'&&c<='9')
          k=k*10+c-48,c=getchar();
        return k;
    }
    LL a[100010],tot,ans[100100];
    int main(){
        LL n=read();
        for(int i=1;i<=sqrt(n);i++)
          if(n%i==0)
            a[++tot]=i,a[++tot]=n/i;
        for(int i=1;i<=tot;i++)        
          ans[i]=(1+(n-a[i]+1))*(n/a[i])/2; //等差数列求和公式
        sort(ans+1,ans+tot+1);
        int pos=unique(ans+1,ans+tot+1)-ans-1;
        for(int i=1;i<=pos;i++) cout<<ans[i]<<" ";
        return 0;
    }
    
  • 相关阅读:
    border-sizing属性详解和应用
    初识scss:配置与运行
    详解scss的继承、占位符和混合宏
    详解promise、async和await的执行顺序
    JS调用模式
    自已写的线程池
    ThreadPool.QueueUserWorkItem的用法
    C#定时执行
    Task.Factory.StartNew的用法
    C#写文本日志帮助类(支持多线程)改进版(不适用于ASP.NET程序)
  • 原文地址:https://www.cnblogs.com/morslin/p/11855028.html
Copyright © 2011-2022 走看看