#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n, r, t, i, ans, cs=1, up, dwn, fac[1000009];
const ll mod=1000003;
ll bigmod(ll b, ll p){
if(p==0) return 1;
ll x=bigmod(b, p/2);
x=(x*x)%mod;
if(p%2==1)x=(x*b)%mod;
return x;
}
int main(){
fac[0]=1;
for(i=1; i<=1000000; i++){
fac[i]=(fac[i-1]*i)%mod;
}
cin>>t;
while(t--){
cin>>n>>r;
up=fac[n];
dwn=(fac[n-r]*fac[r])%mod;
ans=up*bigmod(dwn, mod-2);
cout<<"Case "<<cs++<<": "<<ans%mod<<endl;
}
return 0;
}
|
Friday, January 20, 2017
Solution of Light OJ 1067-Combinations
See the problem Light OJ 1067
Subscribe to:
Post Comments (Atom)
-
#include<bits/stdc++.h> #define ll long long using namespace std ; ll n , k , t_case ; ll bigmod ( ll b , ll p , ll m...
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ...
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3...
No comments:
Post a Comment