QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#260721 | #7802. Game of Nim | Geospiza# | AC ✓ | 115ms | 4808kb | C++20 | 894b | 2023-11-22 14:29:50 | 2023-11-22 14:29:52 |
Judging History
answer
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll int
#define Ma 1000005
#define G 3
#define N 512
#define pb push_back
#define L (1<<21)
using namespace std;
ll dp[N][N];
ll n,p,mod;
void add(ll &x,ll y)
{
x=(x+y)%mod;
return;
}
void sol()
{
cin>>n>>p>>mod;
ll lim=512;
n-=p;
dp[0][0]=1;
for (ll ca=1;ca<=n;ca++)
{
for (ll i=ca;i<=n;i++)
for (ll j=0;j<lim;j++)
add(dp[i][j],dp[i-ca][j^ca]);
}
printf("%d\n",dp[n][p]);
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
int tt=1;
//cin>>tt;
while (tt--)
sol();
return 0;
}
/*
500000 500000
2
5 2
1 2 3 4 5
3 1
4 2
7 3
4 3 1 10 3 8 6
4 9
3 8
4 5
1
5 2
3 5 2 1 1
2 2
3 1
1
6 3
9 14 12 1 5 4
4 3
2 5
1 9
*/
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3524kb
input:
8 3 1000
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
5 2 1000
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3748kb
input:
2 1 2
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3592kb
input:
6 2 1323123
output:
2
result:
ok 1 number(s): "2"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
10 4 123412412
output:
2
result:
ok 1 number(s): "2"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3592kb
input:
20 10 123123
output:
2
result:
ok 1 number(s): "2"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
42 23 231234142
output:
0
result:
ok 1 number(s): "0"
Test #8:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
42 12 123123342
output:
610
result:
ok 1 number(s): "610"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
132 42 198519289
output:
386930
result:
ok 1 number(s): "386930"
Test #10:
score: 0
Accepted
time: 3ms
memory: 3800kb
input:
168 55 190931488
output:
7739643
result:
ok 1 number(s): "7739643"
Test #11:
score: 0
Accepted
time: 8ms
memory: 3828kb
input:
248 119 180187404
output:
5541
result:
ok 1 number(s): "5541"
Test #12:
score: 0
Accepted
time: 35ms
memory: 4140kb
input:
318 39 446463275
output:
309993834
result:
ok 1 number(s): "309993834"
Test #13:
score: 0
Accepted
time: 34ms
memory: 4364kb
input:
464 193 484172941
output:
58956714
result:
ok 1 number(s): "58956714"
Test #14:
score: 0
Accepted
time: 88ms
memory: 4464kb
input:
492 49 509191931
output:
410787599
result:
ok 1 number(s): "410787599"
Test #15:
score: 0
Accepted
time: 68ms
memory: 4612kb
input:
500 100 1000000000
output:
898871667
result:
ok 1 number(s): "898871667"
Test #16:
score: 0
Accepted
time: 41ms
memory: 4132kb
input:
500 200 2424
output:
1571
result:
ok 1 number(s): "1571"
Test #17:
score: 0
Accepted
time: 112ms
memory: 4568kb
input:
500 1 998244353
output:
824962382
result:
ok 1 number(s): "824962382"
Test #18:
score: 0
Accepted
time: 107ms
memory: 4544kb
input:
500 2 999999999
output:
479167812
result:
ok 1 number(s): "479167812"
Test #19:
score: 0
Accepted
time: 110ms
memory: 4528kb
input:
500 5 987654321
output:
888251427
result:
ok 1 number(s): "888251427"
Test #20:
score: 0
Accepted
time: 1ms
memory: 3580kb
input:
500 499 2
output:
0
result:
ok 1 number(s): "0"
Test #21:
score: 0
Accepted
time: 29ms
memory: 4076kb
input:
500 250 4324
output:
203
result:
ok 1 number(s): "203"
Test #22:
score: 0
Accepted
time: 27ms
memory: 4060kb
input:
500 256 1000000000
output:
0
result:
ok 1 number(s): "0"
Test #23:
score: 0
Accepted
time: 28ms
memory: 4068kb
input:
500 255 1000000000
output:
0
result:
ok 1 number(s): "0"
Test #24:
score: 0
Accepted
time: 28ms
memory: 3944kb
input:
500 254 1000000000
output:
0
result:
ok 1 number(s): "0"
Test #25:
score: 0
Accepted
time: 28ms
memory: 4252kb
input:
500 253 1000000000
output:
0
result:
ok 1 number(s): "0"
Test #26:
score: 0
Accepted
time: 29ms
memory: 4064kb
input:
500 252 1000000000
output:
0
result:
ok 1 number(s): "0"
Test #27:
score: 0
Accepted
time: 28ms
memory: 3992kb
input:
500 251 1000000000
output:
0
result:
ok 1 number(s): "0"
Test #28:
score: 0
Accepted
time: 31ms
memory: 4340kb
input:
500 240 1000000000
output:
78752
result:
ok 1 number(s): "78752"
Test #29:
score: 0
Accepted
time: 65ms
memory: 4328kb
input:
500 127 1000000000
output:
735856900
result:
ok 1 number(s): "735856900"
Test #30:
score: 0
Accepted
time: 59ms
memory: 4268kb
input:
500 128 1000000000
output:
752639907
result:
ok 1 number(s): "752639907"
Test #31:
score: 0
Accepted
time: 86ms
memory: 4448kb
input:
500 64 1000000000
output:
696747666
result:
ok 1 number(s): "696747666"
Test #32:
score: 0
Accepted
time: 86ms
memory: 4448kb
input:
500 63 1000000000
output:
372258537
result:
ok 1 number(s): "372258537"
Test #33:
score: 0
Accepted
time: 20ms
memory: 3908kb
input:
333 123 303739951
output:
0
result:
ok 1 number(s): "0"
Test #34:
score: 0
Accepted
time: 84ms
memory: 4648kb
input:
497 55 842080168
output:
0
result:
ok 1 number(s): "0"
Test #35:
score: 0
Accepted
time: 5ms
memory: 3728kb
input:
395 291 982483005
output:
0
result:
ok 1 number(s): "0"
Test #36:
score: 0
Accepted
time: 5ms
memory: 3728kb
input:
481 389 968737780
output:
0
result:
ok 1 number(s): "0"
Test #37:
score: 0
Accepted
time: 33ms
memory: 4112kb
input:
341 74 211356241
output:
0
result:
ok 1 number(s): "0"
Test #38:
score: 0
Accepted
time: 87ms
memory: 4472kb
input:
447 6 220551443
output:
0
result:
ok 1 number(s): "0"
Test #39:
score: 0
Accepted
time: 2ms
memory: 3868kb
input:
117 53 229852993
output:
0
result:
ok 1 number(s): "0"
Test #40:
score: 0
Accepted
time: 36ms
memory: 4140kb
input:
374 92 655232919
output:
510631436
result:
ok 1 number(s): "510631436"
Test #41:
score: 0
Accepted
time: 6ms
memory: 3852kb
input:
161 24 522915247
output:
0
result:
ok 1 number(s): "0"
Test #42:
score: 0
Accepted
time: 1ms
memory: 3780kb
input:
296 264 921737931
output:
0
result:
ok 1 number(s): "0"
Test #43:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
123 59 249153627
output:
0
result:
ok 1 number(s): "0"
Test #44:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
321 289 374745139
output:
0
result:
ok 1 number(s): "0"
Test #45:
score: 0
Accepted
time: 8ms
memory: 4016kb
input:
449 321 564028761
output:
0
result:
ok 1 number(s): "0"
Test #46:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
67 65 193423543
output:
0
result:
ok 1 number(s): "0"
Test #47:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
272 268 89068990
output:
0
result:
ok 1 number(s): "0"
Test #48:
score: 0
Accepted
time: 1ms
memory: 3532kb
input:
491 483 929064777
output:
0
result:
ok 1 number(s): "0"
Test #49:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
344 328 489724616
output:
0
result:
ok 1 number(s): "0"
Test #50:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
362 330 987111640
output:
0
result:
ok 1 number(s): "0"
Test #51:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
255 191 825170913
output:
0
result:
ok 1 number(s): "0"
Test #52:
score: 0
Accepted
time: 8ms
memory: 3796kb
input:
297 169 682131614
output:
0
result:
ok 1 number(s): "0"
Test #53:
score: 0
Accepted
time: 30ms
memory: 4000kb
input:
372 116 897520833
output:
406985347
result:
ok 1 number(s): "406985347"
Test #54:
score: 0
Accepted
time: 30ms
memory: 4016kb
input:
351 95 801600616
output:
0
result:
ok 1 number(s): "0"
Test #55:
score: 0
Accepted
time: 8ms
memory: 4016kb
input:
427 299 527480415
output:
0
result:
ok 1 number(s): "0"
Test #56:
score: 0
Accepted
time: 91ms
memory: 4488kb
input:
493 35 345854681
output:
0
result:
ok 1 number(s): "0"
Test #57:
score: 0
Accepted
time: 76ms
memory: 4424kb
input:
466 45 705433124
output:
405583388
result:
ok 1 number(s): "405583388"
Test #58:
score: 0
Accepted
time: 34ms
memory: 4096kb
input:
295 20 478460925
output:
0
result:
ok 1 number(s): "0"
Test #59:
score: 0
Accepted
time: 80ms
memory: 4604kb
input:
459 38 692239363
output:
0
result:
ok 1 number(s): "0"
Test #60:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
3 1 1000
output:
0
result:
ok 1 number(s): "0"
Test #61:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
3 2 1000
output:
0
result:
ok 1 number(s): "0"
Test #62:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
4 1 1000
output:
1
result:
ok 1 number(s): "1"
Test #63:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
4 2 1000
output:
1
result:
ok 1 number(s): "1"
Test #64:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
4 3 1000
output:
0
result:
ok 1 number(s): "0"
Test #65:
score: 0
Accepted
time: 1ms
memory: 3472kb
input:
8 3 2
output:
0
result:
ok 1 number(s): "0"
Test #66:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
6 1 100
output:
3
result:
ok 1 number(s): "3"
Test #67:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
6 2 100
output:
2
result:
ok 1 number(s): "2"
Test #68:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
6 3 100
output:
2
result:
ok 1 number(s): "2"
Test #69:
score: 0
Accepted
time: 8ms
memory: 3768kb
input:
256 128 123981492
output:
1
result:
ok 1 number(s): "1"
Test #70:
score: 0
Accepted
time: 8ms
memory: 3996kb
input:
254 127 1000000000
output:
877
result:
ok 1 number(s): "877"
Test #71:
score: 0
Accepted
time: 106ms
memory: 4728kb
input:
500 14 958912859
output:
650304186
result:
ok 1 number(s): "650304186"
Test #72:
score: 0
Accepted
time: 94ms
memory: 4584kb
input:
500 42 591829519
output:
133671197
result:
ok 1 number(s): "133671197"
Test #73:
score: 0
Accepted
time: 107ms
memory: 4808kb
input:
499 1 999912321
output:
0
result:
ok 1 number(s): "0"
Test #74:
score: 0
Accepted
time: 1ms
memory: 3820kb
input:
499 498 984129849
output:
0
result:
ok 1 number(s): "0"
Test #75:
score: 0
Accepted
time: 111ms
memory: 4568kb
input:
498 1 918239128
output:
604086379
result:
ok 1 number(s): "604086379"
Test #76:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
498 497 984192849
output:
0
result:
ok 1 number(s): "0"
Test #77:
score: 0
Accepted
time: 8ms
memory: 3828kb
input:
254 127 877
output:
0
result:
ok 1 number(s): "0"
Test #78:
score: 0
Accepted
time: 8ms
memory: 3800kb
input:
254 125 729
output:
0
result:
ok 1 number(s): "0"
Test #79:
score: 0
Accepted
time: 72ms
memory: 4288kb
input:
500 100 613156101
output:
0
result:
ok 1 number(s): "0"
Test #80:
score: 0
Accepted
time: 69ms
memory: 4340kb
input:
500 99 755405164
output:
3
result:
ok 1 number(s): "3"
Test #81:
score: 0
Accepted
time: 72ms
memory: 4392kb
input:
500 99 924361444
output:
924361439
result:
ok 1 number(s): "924361439"
Test #82:
score: 0
Accepted
time: 73ms
memory: 4376kb
input:
500 97 6974800
output:
1
result:
ok 1 number(s): "1"
Test #83:
score: 0
Accepted
time: 69ms
memory: 4376kb
input:
500 96 42601567
output:
42601566
result:
ok 1 number(s): "42601566"
Test #84:
score: 0
Accepted
time: 111ms
memory: 4580kb
input:
500 1 2
output:
1
result:
ok 1 number(s): "1"
Test #85:
score: 0
Accepted
time: 107ms
memory: 4740kb
input:
500 1 5
output:
2
result:
ok 1 number(s): "2"
Test #86:
score: 0
Accepted
time: 115ms
memory: 4484kb
input:
500 1 14
output:
5
result:
ok 1 number(s): "5"
Test #87:
score: 0
Accepted
time: 107ms
memory: 4520kb
input:
500 1 42
output:
33
result:
ok 1 number(s): "33"
Test #88:
score: 0
Accepted
time: 112ms
memory: 4568kb
input:
500 1 132
output:
123
result:
ok 1 number(s): "123"
Test #89:
score: 0
Accepted
time: 111ms
memory: 4492kb
input:
500 1 429
output:
57
result:
ok 1 number(s): "57"
Test #90:
score: 0
Accepted
time: 111ms
memory: 4580kb
input:
500 1 3
output:
0
result:
ok 1 number(s): "0"
Extra Test:
score: 0
Extra Test Passed