zoukankan      html  css  js  c++  java
  • CodeForces Round #654 Div.2

    A. Magical Sticks

    #include <bits/stdc++.h>
    using namespace std;
     
    int T;
     
    int main() {
        scanf("%d", &T);
        while(T --) {
            int N;
            scanf("%d", &N);
            
            if(N == 1 || N == 2) printf("1
    ");
            else {
                if(N % 2) printf("%d
    ", N / 2 + 1);
                else printf("%d
    ", N / 2);
            }
            
        }
        return 0;
    }
    View Code

    B. Magical Calendar

    #include <bits/stdc++.h>
    using namespace std;
     
    int T;
     
    long long Add(long long x) {
        return (1 + x) * x / 2;
    }
     
    int main() {
        scanf("%d", &T);
        while(T --) {
            int N, R;
            long long ans = 0;
     
            scanf("%d%d", &N, &R);
            if(N > R) ans = Add(R);
            else ans = Add(N - 1) + 1;
     
            printf("%lld
    ", ans);
        }
        return 0;
    }
    View Code

    C. A Cookie for You

    #include <bits/stdc++.h>
    using namespace std;
     
    int T;
     
    int main() {
        scanf("%d", &T);
        while(T --) {
            long long a, b, N, M;
            bool flag = false;
     
            scanf("%lld%lld%lld%lld", &a, &b, &N, &M);
            if(a + b < M + N) printf("No
    ");
            else if(min(a, b) < M) printf("No
    ");
            else printf("Yes
    ");
        }
        return 0;
    }
    View Code

     D. Grid-00100

    #include <bits/stdc++.h>
    using namespace std;
    
    const int maxn = 1010;
    int T, N, K;
    int a[maxn][maxn];
    
    int main() {
        scanf("%d", &T);
        while(T --) {
            memset(a, 0, sizeof(a));
            scanf("%d%d", &N, &K);
    
            if(K % N) printf("2
    ");
            else printf("0
    ");
    
            int temp = K % N, rec = K / N;
            for(int i = 0; i < temp; i ++) {
                for(int j = i; j <= i + rec; j ++)
                    a[i][j % N] = 1;
            }
            
            for(int i = temp; i < N; i ++) {
                for(int j = i; j < i + rec; j ++)
                    a[i][j % N] = 1;
            }
    
            for(int i = 0; i < N; i ++) {
                for(int j = 0; j < N; j ++)
                    printf("%d%s", a[i][j], j != N - 1 ? "" : "
    ");
            }
        }
        return 0;
    }
    View Code

    E1. Asterism (Easy Version)

    #include <bits/stdc++.h>
    using namespace std;
    
    const int maxn = 1e5 + 10;
    int N, P;
    int a[maxn];
    
    int main() {
        scanf("%d%d", &N, &P);
        for(int i = 0; i < N; i ++)
            scanf("%d", &a[i]);
    
        sort(a, a + N);
    
        vector<int> ans;
        for(int  i = 1; i <= 2000; i ++) {
            int cnt = 0;
            bool flag = true;
    
            for(int j = 0; j < N; j ++) {
                int pos = upper_bound(a, a + N, i + cnt) - a;
                if(!((pos - cnt) % P)) {
                    flag = false;
                    break;
                }
    
                cnt ++;
    
            }
    
            if(flag) ans.push_back(i);
        }
    
        printf("%d
    ", ans.size());
        for(int i = 0; i < ans.size(); i ++)
            printf("%d%s", ans[i], i != ans.size() - 1 ? " " : "
    ");
    
        return 0;
    }
    View Code
  • 相关阅读:
    Windows下Rails2.0.2最简安装教程
    xmpp with openfire之三 openfire扩展小试 整合现有系统用户
    母亲的电话
    郁闷……
    博弈
    长春下雪了
    监考
    sql把逗号分隔的字符串拆成临时表
    SQL语句使用大全。
    Left Join、Right Join、Inner Join的区别
  • 原文地址:https://www.cnblogs.com/zlrrrr/p/13410100.html
Copyright © 2011-2022 走看看