码迷,mamicode.com
首页 > 其他好文 > 详细

2017-2018 ACM-ICPC Asia East Continent League Final (ECL-Final 2017) 个人题解

时间:2019-10-04 21:07:19      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:space   lse   world   set   res   题解   put   color   sum   

题面:https://codeforces.com/gym/101775

  • A. Chat Group
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
const int maxn = 1e6+10;
const ll mod = 1000000007;

int T;
ll N,K;

ll ksm(ll a,ll b){
    ll res = 1;
    while(b){
        if(b&1) res = res*a%mod;
        a = a*a%mod;
        b>>=1;
    }
    return res;
}

ll solve(){
    ll pre = 1,ck = 1;
    for(ll k = 0;k<=K-2;k++){
        ck = ck*(N-k)%mod*ksm(k+1,mod-2)%mod;
        pre = (pre+ck)%mod;
    }
    return (ksm(2,N)-pre+mod)%mod;
}

int main(){
    cin>>T;
    int kase = 0;
    while(T--){
        cin>>N>>K;
        printf("Case #%d: %lld\n",++kase,solve());
    }
    return 0;
}

 

  • J. Straight Master
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
const int maxn = 1e6+10;

int T,N;
int a[maxn],b[maxn];//原数组,差分数组

bool judge(){
    ll sum = 0;
    for(int i = 1;i<=N+1;i++){
        if(b[i]>0) sum+=b[i];
        if(i+3<=N+1 && b[i+3]<0) sum += b[i+3];
        if(sum<0) return false;
    }
    return sum == 0;
}
int main(){
    cin>>T;
    int kase = 0;
    while(T--){
        memset(a,0,sizeof a);memset(b,0,sizeof b);
        cin>>N;
        for(int i = 1;i<=N;i++) scanf("%d",&a[i]);
        for(int i = 1;i<=N+1;i++) b[i] = a[i]-a[i-1];
        if(judge()) printf("Case #%d: Yes\n",++kase);
        else printf("Case #%d: No\n",++kase);
    }

    return 0;
}
  • L. SOS
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
const int maxn = 1e6+10;
const ll mod = 1000000007;

int T,N;

int main(){
    cin>>T;
    int kase = 0;
    while(T--){
        printf("Case #%d: ",++kase);
        cin>>N;
        if(N<7) puts("Draw");
        else if(N%2 == 1) puts("Panda");
        else if(N%2 == 0 && N>=16) puts("Sheep");
        else puts("Draw");
    }
    return 0;
}
  •  M. World Cup
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
const int maxn = 1e6+10;
const ll mod = 1000000007;

int T,Q,x;
int money[10],p[100];

void init(){
    for(int i = 1;i<=48;i++) p[i] = money[1];
    for(int i = 49;i<=56;i++) p[i] = money[2];
    for(int i = 57;i<=60;i++) p[i] = money[3];
    for(int i = 61;i<=62;i++) p[i] = money[4];
    for(int i = 63;i<=63;i++) p[i] = money[5];
}


int main(){
    cin>>T;
    int kase = 0;
    while(T--){
        for(int i = 1;i<=5;i++) cin>>money[i];
        init();
        cin>>Q;
        ll y = 0;
        while(Q--){
            scanf("%d",&x);
            y += p[x];
        }
        printf("Case #%d: %lld\n",++kase,y*10000);
    }
    return 0;
}

 

2017-2018 ACM-ICPC Asia East Continent League Final (ECL-Final 2017) 个人题解

标签:space   lse   world   set   res   题解   put   color   sum   

原文地址:https://www.cnblogs.com/bigbrox/p/11622966.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!