QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#88548 | #5747. Persian Casino | yyyyxh | AC ✓ | 12ms | 4492kb | C++14 | 1.0kb | 2023-03-16 15:13:56 | 2023-03-16 15:14:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int read(){
char c=getchar();int x=0;
while(c<48||c>57) c=getchar();
do x=(x<<1)+(x<<3)+(c^48),c=getchar();
while(c>=48&&c<=57);
return x;
}
const int P=1000000009;
const int N=100003;
typedef long long ll;
int qp(int a,int b=P-2){
int res=1;
while(b){
if(b&1) res=(ll)res*a%P;
a=(ll)a*a%P;b>>=1;
}
return res;
}
int n,m;
int fac[N],fiv[N];
int C(int n,int k){
if(k<0||k>n) return 0;
return (ll)fac[n]*fiv[k]%P*fiv[n-k]%P;
}
void inc(int &x,int v){if((x+=v)>=P) x-=P;}
void solve(){
n=read();m=read();
bool fl=1;
int pw=1;
for(int i=1;i<=m;++i){
pw<<=1;
if(pw>=n-m){fl=0;break;}
}
if(fl) return void(puts("bankrupt"));
int res=0;
for(int i=0;i<m;++i) inc(res,C(n,i));
inc(res,C(n,m));
printf("%d\n",res);
}
int main(){
fac[0]=1;
for(int i=1;i<=100000;++i) fac[i]=(ll)fac[i-1]*i%P;
fiv[100000]=qp(fac[100000]);
for(int i=100000;i;--i) fiv[i-1]=(ll)fiv[i]*i%P;
int tc=read();
while(tc--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 4492kb
input:
4 2 1 4 1 3 2 57639 34614
output:
3 bankrupt 7 869788168
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 6ms
memory: 4320kb
input:
16460 131 83 137 14 140 28 174 145 87 27 56 11 144 67 88 47 154 59 152 138 100 65 71 43 172 142 113 113 87 68 101 52 179 71 60 51 26 18 97 19 147 111 119 57 124 30 130 37 129 77 177 152 179 84 82 21 162 55 152 2 168 23 139 34 131 101 111 89 179 69 144 30 84 50 150 101 32 24 104 41 137 37 82 59 138 1...
output:
861401790 827411823 937669544 814872401 564368688 774329757 382020028 327399098 136919945 13075099 706031307 579851898 54033422 857164590 919274229 886008600 422741550 229676734 66137152 898506279 95608855 78287335 89291935 599857760 378517272 779874547 58872199 492901833 640116450 bankrupt 73638239...
result:
ok 16460 lines
Test #3:
score: 0
Accepted
time: 12ms
memory: 4264kb
input:
100000 40029 5 1295 16 50862 5 67072 8 51451 4 57967 7 40886 20 13278 1 61885 12 24790 1 80316 2 8554 8 49717 6 82652 8 83139 5 87135 16 7419 8 91357 12 28565 12 80411 1 83723 1 17818 2 36799 20 86016 7 56546 3 92119 10 46290 1 14836 14 63748 1 72859 1 1668 12 99713 23 65337 24 77683 11 36461 2 7810...
output:
bankrupt 670796506 bankrupt bankrupt bankrupt bankrupt 563300247 bankrupt bankrupt bankrupt bankrupt bankrupt bankrupt bankrupt bankrupt bankrupt bankrupt bankrupt bankrupt bankrupt bankrupt bankrupt 58529615 bankrupt bankrupt bankrupt bankrupt 402044100 bankrupt bankrupt 966828094 574753812 1719404...
result:
ok 100000 lines
Test #4:
score: 0
Accepted
time: 5ms
memory: 4260kb
input:
10000 75096 170 52393 157 89622 59 30784 62 92872 10 71076 154 733 160 35387 46 58568 63 96455 37 18043 226 53139 74 66996 90 79664 104 19958 1 84256 54 70524 16 34545 185 91082 181 99565 33 29893 51 87375 453 17413 44 49497 24 9097 67 65189 54 31306 364 85625 117 78290 229 28127 246 34479 59 70644 ...
output:
123012973 875845468 632703855 95015750 bankrupt 294404653 666342970 378538549 154403803 235173547 931628007 563122776 484321021 604232511 bankrupt 35019044 bankrupt 135516031 380981336 246620795 230550839 428361020 878134211 325732400 568531164 25359531 993250912 721937924 313157146 652991298 323782...
result:
ok 10000 lines
Test #5:
score: 0
Accepted
time: 1ms
memory: 4436kb
input:
1000 47644 712 39508 2080 91319 429 85730 193 89231 168 90852 1107 80931 692 44589 1165 61601 951 88695 1910 60519 2251 44003 68 77030 848 9349 3069 70121 21 16638 998 52117 1644 35530 640 30994 2206 86108 136 79242 750 45127 973 45839 2784 75135 1944 81954 937 59327 870 88337 2220 68653 1577 69409 ...
output:
930453873 75883117 911046536 472013732 180280496 362653358 53928715 633333766 652440509 995224796 2931116 590100866 104383855 559878529 608706300 604009562 429916 768495784 835540783 357216087 269067241 729123218 42603437 192775096 966704296 177874111 751921227 752055542 10274469 267675070 599206665...
result:
ok 1000 lines
Test #6:
score: 0
Accepted
time: 6ms
memory: 4272kb
input:
100 73012 3305 96125 11209 80415 981 63939 896 78591 572 56336 7393 48805 3620 98106 6138 64727 9348 63916 10568 64292 13149 88382 7715 41879 582 21638 610 83120 10061 53454 5082 27632 25421 52870 6535 90516 1420 42812 13578 97541 5117 84906 13475 1710 1307 48910 22710 22829 21047 91296 8404 70542 4...
output:
609843775 88816326 639435670 80570776 983663105 275010173 452376363 890900928 979304130 501376054 397915490 642590560 547709565 503383640 850756857 619748066 265186543 374265426 778903446 698174635 47535239 271317915 464149816 828005243 552044237 966214572 996884359 406405556 958845890 896103374 996...
result:
ok 100 lines
Test #7:
score: 0
Accepted
time: 1ms
memory: 4436kb
input:
10 40291 55418 12041 7125 7314 16703 90831 100000 90856 73839 11469 15141 87559 73280 88535 15862 29541 58157 26050 53699
output:
664977345 465309497 968207886 129578339 293314678 308264056 381859983 629103736 434828827 743903142
result:
ok 10 lines
Test #8:
score: 0
Accepted
time: 4ms
memory: 4224kb
input:
173 2063 11 4105 12 32781 15 4113 12 16399 14 12 3 2059 11 3 2 16393 14 16400 14 8205 13 8209 13 520 9 2055 11 6 2 263 8 2058 11 1032 10 4104 12 130 7 72 6 1033 10 25 4 7 2 18 4 8202 13 3 1 73 6 65552 16 37 5 16396 14 131 7 1031 10 33 5 4112 12 7 3 2056 11 138 7 266 8 2061 11 16401 14 65557 16 65551...
output:
bankrupt 949628669 624456594 bankrupt bankrupt bankrupt 426743064 7 927956650 bankrupt 359324602 bankrupt 218127803 536465394 22 679550581 232414418 902513052 774286852 898963933 bankrupt 238097362 bankrupt bankrupt 4048 997045147 4 bankrupt 182966799 510416 935626712 160344802 15888867 284274 bankr...
result:
ok 173 lines
Test #9:
score: 0
Accepted
time: 2ms
memory: 4140kb
input:
1 1 1
output:
2
result:
ok single line: '2'