首页 > 其他 > 详细

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

时间:2019-10-04 20:19:51      阅读:91      评论:0      收藏:0      [点我收藏+]

题面: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;
}

 

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!