zoukankan      html  css  js  c++  java
  • Codeforces Round #643 (Div. 2)

    题目链接:http://codeforces.com/contest/1355

    视频题解链接:https://www.bilibili.com/video/BV1GA411q7K1/

    A.Sequence with Digits

    View Code

    B.Young Explorers

    //
    //  main.cpp
    //  CF
    //
    //  Created by 韩金宇 on 2020/5/15.
    //  Copyright © 2020 韩金宇. All rights reserved.
    //
    
    #include <stdio.h>
    #include <string.h>
    #include <iostream>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <set>
    #include <map>
    #include <list>
    #include <map>
    #include <string>
    #include <math.h>
    #include <stdlib.h>
    #include <time.h>
    using namespace std;
    typedef double db;
    typedef long long ll;
    const int maxn=2e5+10;
    int main()
    {
        #ifdef ONLINE_JUDGE
        #else
            freopen("in.txt","r",stdin);
        #endif
        int T;
        scanf("%d",&T);
        while(T--){
            int n;
            scanf("%d",&n);
            int a[maxn];
            for(int i=0;i<n;i++)
                scanf("%d",a+i);
            sort(a,a+n);
            int ops=0,foo=0,res=0;
            for(int i=0;i<n;i++){
                foo=max(foo,a[i]);
                ops++;
                if(ops==foo){
                    res++;
                    ops=0;
                }
            }
            printf("%d
    ",res);
        }
         return 0;
    }
    View Code

    C.Count Triangles

    //
    //  main.cpp
    //  CF
    //
    //  Created by 韩金宇 on 2020/5/15.
    //  Copyright © 2020 韩金宇. All rights reserved.
    //
    #include <stdio.h>
    #include <string.h>
    #include <iostream>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <set>
    #include <map>
    #include <list>
    #include <map>
    #include <string>
    #include <math.h>
    #include <stdlib.h>
    #include <time.h>
    using namespace std;
    typedef double db;
    typedef long long ll;
    const int maxn=2e5+10;
    int main()
    {
    #ifdef ONLINE_JUDGE
    #else
        freopen("in.txt","r",stdin);
    #endif
        ll a,b,c,d;
        while(~scanf("%lld%lld%lld%lld",&a,&b,&c,&d)){
            ll z=a+b,y=b+c;
            if(z<c+1)
                z=c+1;
            ll sum=0;
            for(ll i=z;i<=y;i++)
            {
                ll yminn=i-a;
                ll xminn=i-b;
                if(yminn>c)
                    yminn=c;
                if(xminn>b)
                    xminn=b;
                xminn=i-xminn;
                ll num=min(d-c+1,i-c);
                sum+=(yminn-xminn+1)*num;
            }
            printf("%lld
    ",sum);
        }
        return 0;
    }
    //1 2 3 4
    //1 2 2 5
    //500000 500000 500000 500000
    View Code

    D.Game With Array

    //
    //  main.cpp
    //  CF
    //
    //  Created by 韩金宇 on 2020/5/15.
    //  Copyright © 2020 韩金宇. All rights reserved.
    //
    
    #include <stdio.h>
    #include <string.h>
    #include <iostream>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <set>
    #include <map>
    #include <list>
    #include <map>
    #include <string>
    #include <math.h>
    #include <stdlib.h>
    #include <time.h>
    using namespace std;
    typedef double db;
    typedef long long ll;
    const int maxn=2e5+10;
    int main()
    {
            #ifdef ONLINE_JUDGE
            #else
                freopen("in.txt","r",stdin);
            #endif
        int n,s;
        scanf("%d%d",&n,&s);
        if(n==1&&s!=1)
        {
            printf("YES
    ");
            printf("%d
    ",s);
            printf("%d
    ",s-1);
        }
        else{
        if(s<(n<<1))
            printf("NO
    ");
        else
        {
            printf("YES
    ");
            if(s%n==0){
                for(int i=0;i<n;i++)
                    printf("%d ",s/n);
                printf("
    ");
                printf("%d
    ",s/n-1);
            }
            else{
            for(int i=0;i<n-1;i++)
                printf("2 ");
            printf("%d
    ",s-((n-1)<<1));
            printf("%d
    ",s-1);
            }
        }
        }
        return 0;
    }
    View Code
  • 相关阅读:
    Python基础之逻辑运算符
    Python基础之赋值运算符
    Python基础之算术运算符
    Python基础之格式化输出
    Python基础之while循环
    Python基础之if语句
    Python基础之注释
    Python基础之变量和常量
    Python基础之Python解释器
    Flask-登录练习
  • 原文地址:https://www.cnblogs.com/Vampire6/p/12904161.html
Copyright © 2011-2022 走看看