QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#225580#5099. 朝圣道chenxinyang200630 1495ms22440kbC++141.7kb2023-10-24 20:13:272023-10-24 20:13:28

Judging History

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

  • [2023-10-24 20:13:28]
  • 评测
  • 测评结果:30
  • 用时:1495ms
  • 内存:22440kb
  • [2023-10-24 20:13:27]
  • 提交

answer

#include <bits/stdc++.h>
#include "pilgrimage.h"
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
//#define mod 998244353
//#define mod 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;

template <class T>
void chkmax(T &x,T y){
	if(x < y) x = y;
}

template <class T>
void chkmin(T &x,T y){
	if(x > y) x = y;
}

inline int popcnt(int x){
	return __builtin_popcount(x);
}

inline int ctz(int x){
	return __builtin_ctz(x);
}

int mod;
ll power(ll p,ll k = mod - 2){
	ll ans = 1;
	while(k){
		if(k % 2 == 1) ans = ans * p % mod;
		p = p * p % mod;
		k /= 2;	
	}
	return ans;
}

ll fact[1000005],ifac[1000005];
ll i2;
ll C(ll N,ll M){
	if(N < M || M < 0) return 0;
	if(N < mod) return fact[N] * ifac[M] % mod * ifac[N - M] % mod;
	return C(N / mod,M / mod) * C(N % mod,M % mod) % mod;
}

ll f(ll N){
	if(N % 2 == 0) return (power(2,N) + C(N,N / 2)) * i2 % mod;
	return power(2,N - 1);
}

void init (int taskid, int _p){
	mod = _p;
	i2 = power(2);
	fact[0] = 1;
	rep(i,1,mod - 1) fact[i] = fact[i - 1] * i % mod;
	ifac[mod - 1] = power(fact[mod - 1]);
	per(i,mod - 2,0) ifac[i] = ifac[i + 1] * (i + 1) % mod; 
}

int ask(ll n){
	n *= 2;
	ll ans = 2 * f(n) - 4 * (f(n - 1) + C(n - 1,n / 2));
	ans %= mod;
	ans *= n % mod;
	ans %= mod;
	if(ans < 0) ans += mod;
	ans = ans * power(i2,n + 1) % mod;
	ans = mod - ans;
	return ans;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 4
Accepted
time: 99ms
memory: 18704kb

input:

1 910276 554767
6
10
7
4
10
12
9
3
3
5
7
10
5
6
1
6
3
9
6
8
12
11
8
2
12
5
9
3
8
2
12
11
2
3
4
9
2
5
5
11
6
4
8
11
3
9
2
2
8
9
2
8
9
6
2
9
2
10
10
7
5
6
4
4
11
12
8
8
2
2
4
3
3
5
6
6
8
11
6
9
9
3
4
1
2
2
6
9
9
2
3
2
12
6
1
7
2
4
12
11
4
7
6
3
9
4
6
5
3
3
12
6
2
1
1
7
2
6
5
9
11
6
3
4
11
1
2
4
5
4
10...

output:

5419
364275
514407
329394
364275
229662
53120
520095
520095
509260
514407
364275
509260
5419
277384
5419
520095
53120
5419
115262
229662
243797
115262
416076
229662
509260
53120
520095
115262
416076
229662
243797
416076
520095
329394
53120
416076
509260
509260
243797
5419
329394
115262
243797
520095...

result:

ok 910276 numbers

Test #2:

score: -4
Wrong Answer
time: 99ms
memory: 14532kb

input:

1 972231 293475
7
1
9
6
5
1
11
5
5
12
2
2
7
3
4
10
10
3
2
10
7
1
10
9
1
3
5
6
7
2
7
4
1
10
1
9
3
10
10
2
6
11
4
10
12
8
5
2
12
4
9
12
7
2
12
4
3
1
2
9
12
1
4
5
6
12
6
5
9
2
5
12
3
4
6
12
12
2
1
6
4
12
10
5
12
7
9
8
3
8
10
5
3
6
12
7
7
10
7
10
8
7
7
2
2
4
8
6
10
8
11
6
11
10
3
9
5
2
5
1
10
2
11
4
4
3...

output:

25956
53043
54492
57258
87015
53043
240573
87015
87015
117246
190416
190416
25956
248394
23802
291555
291555
248394
190416
291555
25956
53043
291555
54492
53043
248394
87015
57258
25956
190416
25956
23802
53043
291555
53043
54492
248394
291555
291555
190416
57258
240573
23802
291555
117246
151509
87...

result:

wrong answer 1st numbers differ - expected: '117936', found: '25956'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 12
Accepted

Test #5:

score: 12
Accepted
time: 4ms
memory: 13624kb

input:

3 1 334547
8234

output:

179079

result:

ok 1 number(s): "179079"

Subtask #4:

score: 18
Accepted

Dependency #3:

100%
Accepted

Test #6:

score: 18
Accepted
time: 435ms
memory: 19352kb

input:

4 1000000 581873
49881
62491
206405
26106
129239
174098
141494
61402
149825
241992
8109
243567
71918
203927
278575
263516
143582
32237
195508
269119
9111
105700
80919
229859
150334
171917
78447
62500
190063
138903
6395
222902
118653
136505
242467
64984
170330
287622
27089
35823
107672
273459
188857
...

output:

225562
278095
494263
533616
449513
172629
433105
169217
156602
470240
127840
224903
148625
143635
385698
428034
270424
224704
326598
317786
205590
556103
563899
492571
87003
417735
350849
476300
65308
462020
373541
56205
35476
425631
345156
395965
377993
402141
119653
299737
4555
400632
420936
58015...

result:

ok 1000000 numbers

Subtask #5:

score: 0
Wrong Answer

Dependency #4:

100%
Accepted

Test #7:

score: 0
Wrong Answer
time: 1495ms
memory: 22440kb

input:

5 1000000 840643
596357868225427095
792903040511847841
549819683428503148
982786835970534376
855138540813992974
101968907510306081
885121351101383723
127972727417081251
728407510651610501
998897446686193527
889398142082696651
17276066104970301
87773104284997915
716559595019194816
538865162230963483
...

output:

840643
149057
840643
840643
840643
840643
13853
840643
840643
840643
618602
840643
840643
840643
840643
840643
243219
264897
840643
840643
840643
840643
840643
840643
840643
840643
840643
840643
840643
840643
311655
840643
840643
840643
670015
171419
840643
840643
840643
840643
840643
840643
840643
...

result:

wrong answer 1st numbers differ - expected: '0', found: '840643'

Subtask #6:

score: 0
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 1415ms
memory: 19036kb

input:

6 958477 522361
280121915553826833
734266539148641647
72849162479700582
274266741463686096
60278972064195458
828423669427600612
571432949203039978
518511460268700898
486268614705621285
19216283231217074
611458416727512530
175147354285288662
799769622289998997
400123443628688299
145546980862133838
40...

output:

196091
391272
181034
469364
424438
486234
329168
56903
12334
379330
281883
206794
422723
512960
507325
93296
336497
273
462609
124824
197659
188930
337386
389193
216370
460334
352716
99862
249011
33656
393526
317625
353185
94878
328937
418131
67935
96418
386533
135723
365148
323862
219177
370482
854...

result:

wrong answer 1st numbers differ - expected: '0', found: '196091'

Subtask #7:

score: 0
Wrong Answer

Dependency #3:

100%
Accepted

Test #13:

score: 0
Wrong Answer
time: 15ms
memory: 19972kb

input:

7 1 731039
314313205082038759

output:

131566

result:

wrong answer 1st numbers differ - expected: '0', found: '131566'

Subtask #8:

score: 0
Wrong Answer

Test #33:

score: 0
Wrong Answer
time: 17ms
memory: 9724kb

input:

8 9963 251
831797004675585320
494759973681332858
701341496127272302
252910460485222469
250965009655458584
366193481309061299
633134388675839346
791999098066205672
196620805863610860
363773642045280947
466508590762410710
407790578717064135
181590911404670570
570642047249889864
70138464625729452
23634...

output:

251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
204
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
251
...

result:

wrong answer 1st numbers differ - expected: '0', found: '251'

Subtask #9:

score: 0
Skipped

Dependency #1:

0%