zoukankan      html  css  js  c++  java
  • 2016-2017 ACM-ICPC CHINA-Final 个人题解

    •  Problem A. Number Theory Problem
    #include <iostream>
    using namespace std;
    const int maxn = 1e6+10;
    typedef long long ll;
    
    int T,N;
    int sec[maxn];
    
    void init(){
        ll cur = 1;
        for(int i = 1;i<=1e5+10;i++){
            cur = cur*2%7;
            if((cur-1+7)%7 == 0) sec[i] = sec[i-1]+1;
            else sec[i] = sec[i-1];
        }
    }
    
    int main(){
        init();
        cin>>T;
        int kase = 0;
        while(T--){
            printf("Case #%d: ",++kase);
            cin>>N;
            printf("%d
    ",sec[N]);
        }
        return 0;
    }
    • Problem D. Ice Cream Tower
    #include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std;
    const int maxn = 1e6+10;
    typedef long long ll;
    
    int T,N,K;
    ll a[maxn];
    
    bool judge(ll n){
        if(n*K>N) return false;
        vector<ll> top(n);
        for(int i = 0;i<n;i++) top[i] = a[i];
        int idx = n;
        for(int i = n;i<n*K;i++){
            while(idx<N && a[idx]<top[i%n]*2) idx++;
            if(idx == N) return false;
            top[i%n] = a[idx++];
        }
        return true;
    }
    
    int sovle(){
        ll l = 0,r = N,mid;
        while(l<r){
            mid = (l+r+1)>>1;
            if(judge(mid)) l = mid;
            else r = mid-1;
        }
        return l;
    }
    
    int main(){
        cin>>T;
        int kase = 0;
        while(T--){
            printf("Case #%d: ",++kase);
            cin>>N>>K;
            for(int i = 0;i<N;i++) scanf("%lld",&a[i]);
            sort(a,a+N);
            int res = sovle();
            printf("%d
    ",res);
        }
    
        return 0;
    }
    • Problem L. World Cup
    #include <iostream>
    #include <cstring>
    using namespace std;
    
    
    int T;
    int a,b,c,d;
    int sc[15][15][15][15];
    int A[3] = {3,1,0},B[3] = {0,1,3};
    
    void init(){
        memset(sc,0,sizeof sc);
        int t1,t2,t3,t4;
        for(int i = 0;i<3;i++){
            for(int j = 0;j<3;j++){
                for(int k = 0;k<3;k++){
                    for(int l =0;l<3;l++){
                        for(int m = 0;m<3;m++){
                            for(int n = 0;n<3;n++){
                                t1 = A[i]+A[j]+A[k];
                                t2 = B[i]+A[l]+A[m];
                                t3 = B[j]+B[l]+A[n];
                                t4 = B[k]+B[m]+B[n];
                                sc[t1][t2][t3][t4]++;
                            }
                        }
                    }
                }
            }
        }
    }
    
    int main(){
        init();
        cin>>T;
        int kase = 0;
        while (T--){
            printf("Case #%d: ",++kase);
            cin>>a>>b>>c>>d;
            if(a>9||b>9||c>9||d>9) puts("Wrong Scoreboard");
            else if(sc[a][b][c][d] == 1) puts("Yes");
            else if(sc[a][b][c][d]>1) puts("No");
            else puts("Wrong Scoreboard");
        }
        return 0;
    }
  • 相关阅读:
    iot 表索引dump《2》
    heap表和iot表排序规则不同
    Cannot complete the install because one or more required items could not be found.
    iot表输出按主键列排序,heap表不是
    iot 表主键存放所有数据,且按数据插入顺序排序
    iot表和heap表排序规则不同
    org.eclipse.graphiti.ui.editor.DiagramEditorInput.
    Oracle 排序规则
    perl 异步超时 打印错误
    14.6.3 Grouping DML Operations with Transactions 组DML操作
  • 原文地址:https://www.cnblogs.com/bigbrox/p/11625713.html
Copyright © 2011-2022 走看看