QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#90895#5747. Persian CasinoMr_EightAC ✓28ms26808kbC++143.0kb2023-03-26 02:24:232023-03-26 02:24:26

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-26 02:24:26]
  • 评测
  • 测评结果:AC
  • 用时:28ms
  • 内存:26808kb
  • [2023-03-26 02:24:23]
  • 提交

answer

//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <climits>
#include <functional>
#include <cstring>
#include <string>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <complex>
#include <random>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/priority_queue.hpp>
#define itn int
#define nit int
#define ll long long
#define ms multiset
#define F(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
#define re register
#define ri re int
#define il inline
#define pii pair<int,int>
#define cp complex<double>
#define vi vector<int>
#define ull unsigned long long
#define mem0(x) memset(x,0,sizeof(x))
#define mem0x3f(x) memset(x,0x3f,sizeof(x))
using namespace std;
//using namespace __gnu_pbds;
const double Pi=acos(-1);
namespace fastIO {
	template<class T>
	inline void read(T &x) {
		x=0;
		bool fu=0;
		char ch=0;
		while(ch>'9'||ch<'0') {
			ch=getchar();
			if(ch=='-')fu=1;
		}
		while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
		if(fu)x=-x;
	}
	inline int read() {
		int x=0;
		bool fu=0;
		char ch=0;
		while(ch>'9'||ch<'0') {
			ch=getchar();
			if(ch=='-')fu=1;
		}
		while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
		return fu?-x:x;
	}
	template<class T,class... Args>
	inline void read(T& t,Args&... args) {
		read(t);
		read(args...);
	}
	char _n_u_m_[40];
	template<class T>
	inline void write(T x) {
		if(x==0){
			putchar('0');
			return;
		}
		T tmp = x > 0 ? x : -x ;
		if( x < 0 ) putchar('-') ;
		int cnt = 0 ;
		while( tmp > 0 ) {
			_n_u_m_[ cnt ++ ] = tmp % 10 + '0' ;
			tmp /= 10 ;
		}
		while( cnt > 0 ) putchar(_n_u_m_[ -- cnt ]) ;
	}
	template<class T>
	inline void write(T x ,char ch) {
		write(x);
		putchar(ch);
	}
}
using namespace fastIO;
int n,m;
const int mod=1e9+9;
long long fac[1000002],ifac[1000002],inv[1000002];
inline long long pw(long long x,long long p){
    long long res=1;
    for(;p;p>>=1,x=x*x%mod)
        if(p&1)res=res*x%mod;
    return res;
}
inline long long getm(long long top,long long bot) {
	return (top*pw(bot,mod-2))%mod;
}
inline long long C(long long top,long long bot){
	if(top<bot||top<0||bot<0)return 0;
	return fac[top]*ifac[bot]%mod*ifac[top-bot]%mod;
}
inline ll s(int tot,int v){
	
}
int main() {
	n=1e6;
	fac[0]=1;
	F(i,1,n)fac[i]=fac[i-1]*i%mod;
	ifac[n]=getm(1,fac[n]);
	UF(i,n-1,0)ifac[i]=ifac[i+1]*(i+1)%mod;
	F(i,1,n)inv[i]=ifac[i]*fac[i-1]%mod;
	F(asdf,1,read()){
		read(n,m);
		if(m>=n){
			write(pw(2,n),'\n');
			continue;
		}
		int c=1<<min(m,30);
		if(c<n-m){
			puts("bankrupt");
			continue;
		}
		ll ans=0,temp=pw(2,n);
		F(i,0,m-1){
			ans+=temp*C(n,i)%mod;
		//	ans-=s(i,i-m);
		}
		ans=getm(ans%mod,temp);
		ans+=C(n,m);/*
		F(i,m,n){
			ans+=C(i-1,m-1)%mod;
		}*/
		write(ans%mod,'\n');
	}
	return 0;
}


詳細信息

Test #1:

score: 100
Accepted
time: 11ms
memory: 26704kb

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: 17ms
memory: 26808kb

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: 28ms
memory: 26732kb

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: 28ms
memory: 26744kb

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: 12ms
memory: 26768kb

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: 25ms
memory: 26740kb

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: 17ms
memory: 26712kb

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: 8ms
memory: 26760kb

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: 22ms
memory: 26760kb

input:

1
1 1

output:

2

result:

ok single line: '2'