| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
不懂就问,我的答案严格小于2^31,为什么错了#include<cstdio>
#include<vector>
#define BN long long
template<typename T>void read(T& a) {
a = 0;
static char ii, li;
ii = getchar();
while(ii > '9' || ii <'0') {
li = ii;
ii = getchar();
}
while(ii <= '9' && ii >= '0') {
a = (a<<3) + (a<<1) + (ii ^ 48);
ii = getchar();
}
if(li == '-')a = -a;
li = ii;
return;
}
template<typename T, typename ...U>void read(T& a, U& ...b) {
read(a),read(b...);
} //2147483648 我的答案严格小于2^31,它告诉我我错了
const long long mod = 2147483659;
long long n, m;
std::vector<long long> inv, pinv;
long long tmp, ans;
int cnt;
int main(){
inv.push_back(1);
pinv.push_back(1);
cnt = 2;
while(1){
read(n, m);
if(n == 0)break;
if(2 * m > n){
m = n - m;
}
for(;cnt <= m; cnt++){
tmp = mod - (mod / cnt * inv[(mod % cnt) - 1] % mod) % mod;
inv.push_back(tmp);
pinv.push_back(pinv.back() * tmp % mod);
}
ans = 1;
for(int i = 1; i <= m; i++, n--){
ans *= n;
ans %= mod;
}
ans *= pinv[m - 1];
ans %= mod;
printf("%lld\n", ans);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator