深圳大学2018集训 August 24 团队积分赛 #4 2017-2018 ACM-ICPC Asia East Continent League Final (ECL-Final 2017)...

题目是 2017-2018 ACM-ICPC Asia East Continent League Final (ECL-Final 2017)
一共13题,最后打了4道题就走了,训练的时候队伍完全不在状态,还是感觉比赛要凉凉。
还是做一次题解记录好了。

题目来源:http://codeforces.com/gym/101775

A. Chat Group

time limit per test1.0 s
memory limit per test256 MB
inputstandard input
outputstandard output
It is said that a dormitory with 6 persons has 7 chat groups ^_^. But the number can be even larger: since every 3 or more persons could make a chat group, there can be 42 different chat groups.

Given N persons in a dormitory, and every K or more persons could make a chat group, how many different chat groups could there be?

Input
The input starts with one line containing exactly one integer T which is the number of test cases.

Each test case contains one line with two integers N and K indicating the number of persons in a dormitory and the minimum number of persons that could make a chat group.

1 ≤ T ≤ 100.
1 ≤ N ≤ 109.
3 ≤ K ≤ 105.
Output
For each test case, output one line containing "Case #x: y" where x is the test case number (starting from 1) and y is the number of different chat groups modulo 1000000007.

大意:从N个人中选择至少K个人,有多少种不同的选择方法。

思路:对排列组合求合,题目中N比较大,而可以选择计算出N个人的所有选择方法(2^N)然后在减去选出小于K个人的方法。
2^N要用到快速幂,而排列组合的求和一开始我是直接求,然后超时,wbl加上了费马小定理后,还是超时,最后从别的队哪里提到了,排列组合求和时要用递推公式,之前每一个排列都求一次实在是太蠢了。

最后代码

#include<bits/stdc++.h>
#define MOD 1000000007

using namespace std;
typedef long long ll;
ll f[10001];
ll mod_pow(ll x,ll n,ll mod){
    ll res=1;
    while(n>0){
        if(n&1)res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
const int MAXN=2020;
int T,N,K,cas=1;

int main(){
    ll mul=1;
    cin>>T;
    while(T--){
        cin>>N>>K;
        //ll ans=mod_pow(2,N,MOD)-mod_pow(2,K,MOD);
        //cout<<mod_pow(2,N,MOD)<<" "<<mod_pow(2,K,MOD)<<endl;
        //cout<<ans<<endl;
        ll ans=mod_pow(2,N,MOD);
        //cout<<ans<<endl;
        ll fm=1,fz=1;
        for(ll i=0;i<K;i++){
            if(i)fm=fm*i%MOD,fz=fz*(N-i+1)%MOD;
            ll C=fz*mod_pow(fm,MOD-2,MOD)%MOD;
      //      cout<<C<<endl;
            ans=(ans-C+MOD)%MOD;
        }
        cout<<"Case #"<<cas++<<": ";
        cout<<ans<<endl;
    }
    return 0;
}

B Scapegoat
思路是对的但中途没有优先队列,而且也超时了。

C. Traffic Light

这道题看懂了题目意思后实在太简单了,要求的值就是所有路径的和加上最长的红灯时间。只不过想要想到原因不容易罢了。

K. Downgrade

一开始读题就很困难,主要是题目中降级的机制我们都没看懂,最后看懂了题目意思后,wbl打了第一版代码,然后TL,我改了cin为scanf、加了一个中途等级不变就跳出,然后就AC了。

M. World Cup
这道题完全由lgx一个人打的。

赛后反思:
第一是队伍里面数论只有wbl,我和lgx都不过关,这次的费马小定理、逆原、上次的高斯消元的题目做起来就很头疼。
第二是队伍的英语能力实在是不足,读题问题很多,花费的时间也很长。

改进思路:
第一肯定是基础理论的学习,然后是英语的问题,这个是真的头疼,第三是模板要带好,训练时优先队列和wbl 用lower_bound( )和upper_bound( )又出了问题。

总结:
凉凉

待补充。。。

转载于:https://www.cnblogs.com/lingyuanchuang/p/9528340.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值