题目链接:Chat Group
/*
* [链接]:https://codeforces.com/gym/101775/problem/A
*
* [题意]:给出n,m。问:从n个人中至少选m个人的方案数。
*
* [分析]: 由于n很大,m很小,因此考虑二项式,因此ans=2^n-C(n,i),i-->[0,n-1],C(n,i)递推即可。
*
* [tricks]:
*
* [时间复杂度]:
*
* */
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void scan() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
const ll mod = 1e9 + 7;
const int maxn = 1e5 + 7;
ll fac[maxn], n, m;
ll ksm(ll a, ll b) {
ll ans = 1;
while (b) {
if (b & 1) ans = ans * a % mod;
b >>= 1;
a = a * a % mod;
}
return ans;
}
int main() {
ios::sync_with_stdio(false), cin.tie(0);//, cout.tie(0);
scan();
int t;
cin >> t;
for (ll i = 1; i < maxn; i++) fac[i] = ksm(i, mod - 2);
for (int cas = 1; cas <= t; cas++) {
cin >> n >> m;
ll ans = ksm(2ll, n), tmp = 1;
for (ll i = 0; i < m; i++) {
ans = (ans - tmp + mod) % mod;
tmp = (tmp * (n - i) % mod * fac[i + 1] % mod) % mod;
}
printf("Case #%d: %lld\n", cas, ans);
}
return 0;
}
题目链接:World Cup
/*
* [链接]:https://codeforces.com/gym/101775/problem/M
*
* [题意]:模拟即可。
*
* [分析]:
*
* [tricks]:
*
* [时间复杂度]:
*
* */
#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;
const long long maxn = 1e6 + 7;
ll a[maxn];
long long solve(long long cas) {
for (long long i = 1; i <= 5; i++) cin >> a[i];
cout << "Case #" << cas << ": ";
int q;
cin >> q;
ll ans = 0;
while (q--) {
int x;
cin >> x;
if (x <= 48) ans += a[1];
else if (x <= 56) ans += a[2];
else if (x <= 60) ans += a[3];
else if (x <= 62) ans += a[4];
else ans += a[5];
}
cout << ans << "0000" << endl;
}
int main() {
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
long long T;
cin >> T;
for (long long i = 1; i <= T; i++) {
solve(i);
}
return 0;
}