QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#333759 | #7802. Game of Nim | yhk1001 | AC ✓ | 166ms | 511820kb | C++14 | 823b | 2024-02-20 14:59:21 | 2024-02-20 14:59:21 |
Judging History
answer
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
// #define Debug
// #define LOCAL
// #define TestCases
const int N = 500, V = 512;
int n, p, m;
int dp[N + 5][N + 5][V + 5];
void solve()
{
cin >> n >> p >> m;
n -= p;
dp[0][0][0] = 1;
for (int i = 1; i <= n; i++)//have considered 1 ~ i
for (int j = 0; j <= n; j++)//used stones = j
for (int k = 0; k <= V; k++)//xor sum = k
{
dp[i][j][k] = dp[i - 1][j][k];
if (j >= i)
dp[i][j][k] = (dp[i][j][k] + dp[i][j - i][k ^ i]) % m;
}
printf("%d\n", dp[n][n][p]);
return ;
}
int main()
{
#ifdef LOCAL
freopen("data.in", "r", stdin);
freopen("mycode.out", "w", stdout);
#endif
int T = 1;
#ifdef TestCases
scanf("%d", &T);
#endif
while (T--)
solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 9868kb
input:
8 3 1000
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 5948kb
input:
5 2 1000
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
2 1 2
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 1ms
memory: 7892kb
input:
6 2 1323123
output:
2
result:
ok 1 number(s): "2"
Test #5:
score: 0
Accepted
time: 2ms
memory: 9948kb
input:
10 4 123412412
output:
2
result:
ok 1 number(s): "2"
Test #6:
score: 0
Accepted
time: 0ms
memory: 14020kb
input:
20 10 123123
output:
2
result:
ok 1 number(s): "2"
Test #7:
score: 0
Accepted
time: 0ms
memory: 24288kb
input:
42 23 231234142
output:
0
result:
ok 1 number(s): "0"
Test #8:
score: 0
Accepted
time: 0ms
memory: 34440kb
input:
42 12 123123342
output:
610
result:
ok 1 number(s): "610"
Test #9:
score: 0
Accepted
time: 8ms
memory: 92412kb
input:
132 42 198519289
output:
386930
result:
ok 1 number(s): "386930"
Test #10:
score: 0
Accepted
time: 12ms
memory: 85560kb
input:
168 55 190931488
output:
7739643
result:
ok 1 number(s): "7739643"
Test #11:
score: 0
Accepted
time: 4ms
memory: 91200kb
input:
248 119 180187404
output:
5541
result:
ok 1 number(s): "5541"
Test #12:
score: 0
Accepted
time: 32ms
memory: 204140kb
input:
318 39 446463275
output:
309993834
result:
ok 1 number(s): "309993834"
Test #13:
score: 0
Accepted
time: 35ms
memory: 197916kb
input:
464 193 484172941
output:
58956714
result:
ok 1 number(s): "58956714"
Test #14:
score: 0
Accepted
time: 104ms
memory: 414152kb
input:
492 49 509191931
output:
410787599
result:
ok 1 number(s): "410787599"
Test #15:
score: 0
Accepted
time: 116ms
memory: 348964kb
input:
500 100 1000000000
output:
898871667
result:
ok 1 number(s): "898871667"
Test #16:
score: 0
Accepted
time: 39ms
memory: 227036kb
input:
500 200 2424
output:
1571
result:
ok 1 number(s): "1571"
Test #17:
score: 0
Accepted
time: 166ms
memory: 510800kb
input:
500 1 998244353
output:
824962382
result:
ok 1 number(s): "824962382"
Test #18:
score: 0
Accepted
time: 103ms
memory: 509820kb
input:
500 2 999999999
output:
479167812
result:
ok 1 number(s): "479167812"
Test #19:
score: 0
Accepted
time: 131ms
memory: 504776kb
input:
500 5 987654321
output:
888251427
result:
ok 1 number(s): "888251427"
Test #20:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
500 499 2
output:
0
result:
ok 1 number(s): "0"
Test #21:
score: 0
Accepted
time: 35ms
memory: 233828kb
input:
500 250 4324
output:
203
result:
ok 1 number(s): "203"
Test #22:
score: 0
Accepted
time: 27ms
memory: 229984kb
input:
500 256 1000000000
output:
0
result:
ok 1 number(s): "0"
Test #23:
score: 0
Accepted
time: 23ms
memory: 231872kb
input:
500 255 1000000000
output:
0
result:
ok 1 number(s): "0"
Test #24:
score: 0
Accepted
time: 28ms
memory: 229072kb
input:
500 254 1000000000
output:
0
result:
ok 1 number(s): "0"
Test #25:
score: 0
Accepted
time: 28ms
memory: 231896kb
input:
500 253 1000000000
output:
0
result:
ok 1 number(s): "0"
Test #26:
score: 0
Accepted
time: 35ms
memory: 233816kb
input:
500 252 1000000000
output:
0
result:
ok 1 number(s): "0"
Test #27:
score: 0
Accepted
time: 20ms
memory: 233024kb
input:
500 251 1000000000
output:
0
result:
ok 1 number(s): "0"
Test #28:
score: 0
Accepted
time: 35ms
memory: 241056kb
input:
500 240 1000000000
output:
78752
result:
ok 1 number(s): "78752"
Test #29:
score: 0
Accepted
time: 68ms
memory: 339796kb
input:
500 127 1000000000
output:
735856900
result:
ok 1 number(s): "735856900"
Test #30:
score: 0
Accepted
time: 87ms
memory: 338232kb
input:
500 128 1000000000
output:
752639907
result:
ok 1 number(s): "752639907"
Test #31:
score: 0
Accepted
time: 115ms
memory: 416308kb
input:
500 64 1000000000
output:
696747666
result:
ok 1 number(s): "696747666"
Test #32:
score: 0
Accepted
time: 96ms
memory: 418252kb
input:
500 63 1000000000
output:
372258537
result:
ok 1 number(s): "372258537"
Test #33:
score: 0
Accepted
time: 11ms
memory: 210072kb
input:
333 123 303739951
output:
0
result:
ok 1 number(s): "0"
Test #34:
score: 0
Accepted
time: 91ms
memory: 424708kb
input:
497 55 842080168
output:
0
result:
ok 1 number(s): "0"
Test #35:
score: 0
Accepted
time: 0ms
memory: 110300kb
input:
395 291 982483005
output:
0
result:
ok 1 number(s): "0"
Test #36:
score: 0
Accepted
time: 3ms
memory: 98004kb
input:
481 389 968737780
output:
0
result:
ok 1 number(s): "0"
Test #37:
score: 0
Accepted
time: 32ms
memory: 231412kb
input:
341 74 211356241
output:
0
result:
ok 1 number(s): "0"
Test #38:
score: 0
Accepted
time: 87ms
memory: 424876kb
input:
447 6 220551443
output:
0
result:
ok 1 number(s): "0"
Test #39:
score: 0
Accepted
time: 3ms
memory: 69580kb
input:
117 53 229852993
output:
0
result:
ok 1 number(s): "0"
Test #40:
score: 0
Accepted
time: 49ms
memory: 256380kb
input:
374 92 655232919
output:
510631436
result:
ok 1 number(s): "510631436"
Test #41:
score: 0
Accepted
time: 12ms
memory: 143352kb
input:
161 24 522915247
output:
0
result:
ok 1 number(s): "0"
Test #42:
score: 0
Accepted
time: 3ms
memory: 36568kb
input:
296 264 921737931
output:
0
result:
ok 1 number(s): "0"
Test #43:
score: 0
Accepted
time: 0ms
memory: 69552kb
input:
123 59 249153627
output:
0
result:
ok 1 number(s): "0"
Test #44:
score: 0
Accepted
time: 3ms
memory: 34592kb
input:
321 289 374745139
output:
0
result:
ok 1 number(s): "0"
Test #45:
score: 0
Accepted
time: 12ms
memory: 134892kb
input:
449 321 564028761
output:
0
result:
ok 1 number(s): "0"
Test #46:
score: 0
Accepted
time: 0ms
memory: 5860kb
input:
67 65 193423543
output:
0
result:
ok 1 number(s): "0"
Test #47:
score: 0
Accepted
time: 0ms
memory: 7904kb
input:
272 268 89068990
output:
0
result:
ok 1 number(s): "0"
Test #48:
score: 0
Accepted
time: 2ms
memory: 11996kb
input:
491 483 929064777
output:
0
result:
ok 1 number(s): "0"
Test #49:
score: 0
Accepted
time: 0ms
memory: 20268kb
input:
344 328 489724616
output:
0
result:
ok 1 number(s): "0"
Test #50:
score: 0
Accepted
time: 0ms
memory: 36476kb
input:
362 330 987111640
output:
0
result:
ok 1 number(s): "0"
Test #51:
score: 0
Accepted
time: 3ms
memory: 69288kb
input:
255 191 825170913
output:
0
result:
ok 1 number(s): "0"
Test #52:
score: 0
Accepted
time: 11ms
memory: 135016kb
input:
297 169 682131614
output:
0
result:
ok 1 number(s): "0"
Test #53:
score: 0
Accepted
time: 32ms
memory: 228304kb
input:
372 116 897520833
output:
406985347
result:
ok 1 number(s): "406985347"
Test #54:
score: 0
Accepted
time: 44ms
memory: 230356kb
input:
351 95 801600616
output:
0
result:
ok 1 number(s): "0"
Test #55:
score: 0
Accepted
time: 7ms
memory: 135208kb
input:
427 299 527480415
output:
0
result:
ok 1 number(s): "0"
Test #56:
score: 0
Accepted
time: 108ms
memory: 447516kb
input:
493 35 345854681
output:
0
result:
ok 1 number(s): "0"
Test #57:
score: 0
Accepted
time: 71ms
memory: 400372kb
input:
466 45 705433124
output:
405583388
result:
ok 1 number(s): "405583388"
Test #58:
score: 0
Accepted
time: 46ms
memory: 257668kb
input:
295 20 478460925
output:
0
result:
ok 1 number(s): "0"
Test #59:
score: 0
Accepted
time: 111ms
memory: 400104kb
input:
459 38 692239363
output:
0
result:
ok 1 number(s): "0"
Test #60:
score: 0
Accepted
time: 1ms
memory: 5936kb
input:
3 1 1000
output:
0
result:
ok 1 number(s): "0"
Test #61:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
3 2 1000
output:
0
result:
ok 1 number(s): "0"
Test #62:
score: 0
Accepted
time: 0ms
memory: 7852kb
input:
4 1 1000
output:
1
result:
ok 1 number(s): "1"
Test #63:
score: 0
Accepted
time: 0ms
memory: 5848kb
input:
4 2 1000
output:
1
result:
ok 1 number(s): "1"
Test #64:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
4 3 1000
output:
0
result:
ok 1 number(s): "0"
Test #65:
score: 0
Accepted
time: 2ms
memory: 9900kb
input:
8 3 2
output:
0
result:
ok 1 number(s): "0"
Test #66:
score: 0
Accepted
time: 2ms
memory: 10032kb
input:
6 1 100
output:
3
result:
ok 1 number(s): "3"
Test #67:
score: 0
Accepted
time: 0ms
memory: 7852kb
input:
6 2 100
output:
2
result:
ok 1 number(s): "2"
Test #68:
score: 0
Accepted
time: 1ms
memory: 5940kb
input:
6 3 100
output:
2
result:
ok 1 number(s): "2"
Test #69:
score: 0
Accepted
time: 12ms
memory: 135136kb
input:
256 128 123981492
output:
1
result:
ok 1 number(s): "1"
Test #70:
score: 0
Accepted
time: 0ms
memory: 134956kb
input:
254 127 1000000000
output:
877
result:
ok 1 number(s): "877"
Test #71:
score: 0
Accepted
time: 111ms
memory: 490976kb
input:
500 14 958912859
output:
650304186
result:
ok 1 number(s): "650304186"
Test #72:
score: 0
Accepted
time: 114ms
memory: 449420kb
input:
500 42 591829519
output:
133671197
result:
ok 1 number(s): "133671197"
Test #73:
score: 0
Accepted
time: 122ms
memory: 509436kb
input:
499 1 999912321
output:
0
result:
ok 1 number(s): "0"
Test #74:
score: 0
Accepted
time: 1ms
memory: 5780kb
input:
499 498 984129849
output:
0
result:
ok 1 number(s): "0"
Test #75:
score: 0
Accepted
time: 112ms
memory: 507728kb
input:
498 1 918239128
output:
604086379
result:
ok 1 number(s): "604086379"
Test #76:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
498 497 984192849
output:
0
result:
ok 1 number(s): "0"
Test #77:
score: 0
Accepted
time: 11ms
memory: 134876kb
input:
254 127 877
output:
0
result:
ok 1 number(s): "0"
Test #78:
score: 0
Accepted
time: 15ms
memory: 136876kb
input:
254 125 729
output:
0
result:
ok 1 number(s): "0"
Test #79:
score: 0
Accepted
time: 97ms
memory: 376936kb
input:
500 100 613156101
output:
0
result:
ok 1 number(s): "0"
Test #80:
score: 0
Accepted
time: 75ms
memory: 377688kb
input:
500 99 755405164
output:
3
result:
ok 1 number(s): "3"
Test #81:
score: 0
Accepted
time: 71ms
memory: 381800kb
input:
500 99 924361444
output:
924361439
result:
ok 1 number(s): "924361439"
Test #82:
score: 0
Accepted
time: 75ms
memory: 383556kb
input:
500 97 6974800
output:
1
result:
ok 1 number(s): "1"
Test #83:
score: 0
Accepted
time: 76ms
memory: 384688kb
input:
500 96 42601567
output:
42601566
result:
ok 1 number(s): "42601566"
Test #84:
score: 0
Accepted
time: 151ms
memory: 511076kb
input:
500 1 2
output:
1
result:
ok 1 number(s): "1"
Test #85:
score: 0
Accepted
time: 136ms
memory: 511820kb
input:
500 1 5
output:
2
result:
ok 1 number(s): "2"
Test #86:
score: 0
Accepted
time: 119ms
memory: 511172kb
input:
500 1 14
output:
5
result:
ok 1 number(s): "5"
Test #87:
score: 0
Accepted
time: 120ms
memory: 511160kb
input:
500 1 42
output:
33
result:
ok 1 number(s): "33"
Test #88:
score: 0
Accepted
time: 128ms
memory: 511116kb
input:
500 1 132
output:
123
result:
ok 1 number(s): "123"
Test #89:
score: 0
Accepted
time: 131ms
memory: 511248kb
input:
500 1 429
output:
57
result:
ok 1 number(s): "57"
Test #90:
score: 0
Accepted
time: 133ms
memory: 511360kb
input:
500 1 3
output:
0
result:
ok 1 number(s): "0"
Extra Test:
score: 0
Extra Test Passed