QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#710118#7802. Game of NimbecaidoAC ✓202ms4740kbC++201.1kb2024-11-04 18:43:552024-11-04 18:43:56

Judging History

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

  • [2024-11-04 18:43:56]
  • 评测
  • 测评结果:AC
  • 用时:202ms
  • 内存:4740kb
  • [2024-11-04 18:43:55]
  • 提交

answer

#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#ifdef WAIMAI
#define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE)
void dout() {cout << '\n';}
template<typename T, typename...U>
void dout (T t, U...u) {cout << t << (sizeof... (u) ? ", " : ""), dout (u...);}
#else
#define debug(...) 7122
#endif

#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second

const int SIZE = 520;

int n, m, p, mod;
int dp[SIZE][SIZE];

inline void add(int &x, const int &y) {
    x += y;
    if (x >= mod) x -= mod;
}

void solve() {
    cin >> n >> p >> mod;
    dp[0][p] = 1;
    m = 1 << (__lg(n - 1) + 1);
    n -= p;
    FOR (x, 1, n) for (int sum = n; sum >= 0; sum--) FOR (k, 1, n / x) {
        int y = x * k, v = (k % 2 ? x : 0);
        if (sum + y <= n) for (int val = 0; val < m; val++) if (dp[sum][val]) {
            add(dp[sum + y][val ^ v], dp[sum][val]);
        }
    }
    cout << dp[n][0] << '\n';
}

int main() {
    Waimai;
    solve();
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3732kb

input:

8 3 1000

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

5 2 1000

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3728kb

input:

2 1 2

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

6 2 1323123

output:

2

result:

ok 1 number(s): "2"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

10 4 123412412

output:

2

result:

ok 1 number(s): "2"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

20 10 123123

output:

2

result:

ok 1 number(s): "2"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

42 23 231234142

output:

0

result:

ok 1 number(s): "0"

Test #8:

score: 0
Accepted
time: 1ms
memory: 3784kb

input:

42 12 123123342

output:

610

result:

ok 1 number(s): "610"

Test #9:

score: 0
Accepted
time: 3ms
memory: 3780kb

input:

132 42 198519289

output:

386930

result:

ok 1 number(s): "386930"

Test #10:

score: 0
Accepted
time: 4ms
memory: 3816kb

input:

168 55 190931488

output:

7739643

result:

ok 1 number(s): "7739643"

Test #11:

score: 0
Accepted
time: 5ms
memory: 3844kb

input:

248 119 180187404

output:

5541

result:

ok 1 number(s): "5541"

Test #12:

score: 0
Accepted
time: 51ms
memory: 4236kb

input:

318 39 446463275

output:

309993834

result:

ok 1 number(s): "309993834"

Test #13:

score: 0
Accepted
time: 48ms
memory: 4208kb

input:

464 193 484172941

output:

58956714

result:

ok 1 number(s): "58956714"

Test #14:

score: 0
Accepted
time: 139ms
memory: 4580kb

input:

492 49 509191931

output:

410787599

result:

ok 1 number(s): "410787599"

Test #15:

score: 0
Accepted
time: 103ms
memory: 4528kb

input:

500 100 1000000000

output:

898871667

result:

ok 1 number(s): "898871667"

Test #16:

score: 0
Accepted
time: 61ms
memory: 4260kb

input:

500 200 2424

output:

1571

result:

ok 1 number(s): "1571"

Test #17:

score: 0
Accepted
time: 179ms
memory: 4684kb

input:

500 1 998244353

output:

824962382

result:

ok 1 number(s): "824962382"

Test #18:

score: 0
Accepted
time: 178ms
memory: 4680kb

input:

500 2 999999999

output:

479167812

result:

ok 1 number(s): "479167812"

Test #19:

score: 0
Accepted
time: 176ms
memory: 4600kb

input:

500 5 987654321

output:

888251427

result:

ok 1 number(s): "888251427"

Test #20:

score: 0
Accepted
time: 0ms
memory: 3728kb

input:

500 499 2

output:

0

result:

ok 1 number(s): "0"

Test #21:

score: 0
Accepted
time: 41ms
memory: 4228kb

input:

500 250 4324

output:

203

result:

ok 1 number(s): "203"

Test #22:

score: 0
Accepted
time: 39ms
memory: 4032kb

input:

500 256 1000000000

output:

0

result:

ok 1 number(s): "0"

Test #23:

score: 0
Accepted
time: 35ms
memory: 4136kb

input:

500 255 1000000000

output:

0

result:

ok 1 number(s): "0"

Test #24:

score: 0
Accepted
time: 39ms
memory: 4228kb

input:

500 254 1000000000

output:

0

result:

ok 1 number(s): "0"

Test #25:

score: 0
Accepted
time: 40ms
memory: 4092kb

input:

500 253 1000000000

output:

0

result:

ok 1 number(s): "0"

Test #26:

score: 0
Accepted
time: 43ms
memory: 4160kb

input:

500 252 1000000000

output:

0

result:

ok 1 number(s): "0"

Test #27:

score: 0
Accepted
time: 40ms
memory: 4096kb

input:

500 251 1000000000

output:

0

result:

ok 1 number(s): "0"

Test #28:

score: 0
Accepted
time: 45ms
memory: 4248kb

input:

500 240 1000000000

output:

78752

result:

ok 1 number(s): "78752"

Test #29:

score: 0
Accepted
time: 95ms
memory: 4428kb

input:

500 127 1000000000

output:

735856900

result:

ok 1 number(s): "735856900"

Test #30:

score: 0
Accepted
time: 94ms
memory: 4428kb

input:

500 128 1000000000

output:

752639907

result:

ok 1 number(s): "752639907"

Test #31:

score: 0
Accepted
time: 137ms
memory: 4552kb

input:

500 64 1000000000

output:

696747666

result:

ok 1 number(s): "696747666"

Test #32:

score: 0
Accepted
time: 130ms
memory: 4480kb

input:

500 63 1000000000

output:

372258537

result:

ok 1 number(s): "372258537"

Test #33:

score: 0
Accepted
time: 27ms
memory: 4016kb

input:

333 123 303739951

output:

0

result:

ok 1 number(s): "0"

Test #34:

score: 0
Accepted
time: 139ms
memory: 4564kb

input:

497 55 842080168

output:

0

result:

ok 1 number(s): "0"

Test #35:

score: 0
Accepted
time: 6ms
memory: 3876kb

input:

395 291 982483005

output:

0

result:

ok 1 number(s): "0"

Test #36:

score: 0
Accepted
time: 5ms
memory: 3900kb

input:

481 389 968737780

output:

0

result:

ok 1 number(s): "0"

Test #37:

score: 0
Accepted
time: 47ms
memory: 4212kb

input:

341 74 211356241

output:

0

result:

ok 1 number(s): "0"

Test #38:

score: 0
Accepted
time: 139ms
memory: 4612kb

input:

447 6 220551443

output:

0

result:

ok 1 number(s): "0"

Test #39:

score: 0
Accepted
time: 1ms
memory: 3792kb

input:

117 53 229852993

output:

0

result:

ok 1 number(s): "0"

Test #40:

score: 0
Accepted
time: 48ms
memory: 4224kb

input:

374 92 655232919

output:

510631436

result:

ok 1 number(s): "510631436"

Test #41:

score: 0
Accepted
time: 3ms
memory: 3944kb

input:

161 24 522915247

output:

0

result:

ok 1 number(s): "0"

Test #42:

score: 0
Accepted
time: 1ms
memory: 3736kb

input:

296 264 921737931

output:

0

result:

ok 1 number(s): "0"

Test #43:

score: 0
Accepted
time: 1ms
memory: 3776kb

input:

123 59 249153627

output:

0

result:

ok 1 number(s): "0"

Test #44:

score: 0
Accepted
time: 1ms
memory: 3780kb

input:

321 289 374745139

output:

0

result:

ok 1 number(s): "0"

Test #45:

score: 0
Accepted
time: 10ms
memory: 3796kb

input:

449 321 564028761

output:

0

result:

ok 1 number(s): "0"

Test #46:

score: 0
Accepted
time: 0ms
memory: 3728kb

input:

67 65 193423543

output:

0

result:

ok 1 number(s): "0"

Test #47:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

272 268 89068990

output:

0

result:

ok 1 number(s): "0"

Test #48:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

491 483 929064777

output:

0

result:

ok 1 number(s): "0"

Test #49:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

344 328 489724616

output:

0

result:

ok 1 number(s): "0"

Test #50:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

362 330 987111640

output:

0

result:

ok 1 number(s): "0"

Test #51:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

255 191 825170913

output:

0

result:

ok 1 number(s): "0"

Test #52:

score: 0
Accepted
time: 10ms
memory: 3924kb

input:

297 169 682131614

output:

0

result:

ok 1 number(s): "0"

Test #53:

score: 0
Accepted
time: 43ms
memory: 4160kb

input:

372 116 897520833

output:

406985347

result:

ok 1 number(s): "406985347"

Test #54:

score: 0
Accepted
time: 43ms
memory: 4156kb

input:

351 95 801600616

output:

0

result:

ok 1 number(s): "0"

Test #55:

score: 0
Accepted
time: 10ms
memory: 3916kb

input:

427 299 527480415

output:

0

result:

ok 1 number(s): "0"

Test #56:

score: 0
Accepted
time: 149ms
memory: 4652kb

input:

493 35 345854681

output:

0

result:

ok 1 number(s): "0"

Test #57:

score: 0
Accepted
time: 125ms
memory: 4476kb

input:

466 45 705433124

output:

405583388

result:

ok 1 number(s): "405583388"

Test #58:

score: 0
Accepted
time: 50ms
memory: 4228kb

input:

295 20 478460925

output:

0

result:

ok 1 number(s): "0"

Test #59:

score: 0
Accepted
time: 125ms
memory: 4576kb

input:

459 38 692239363

output:

0

result:

ok 1 number(s): "0"

Test #60:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

3 1 1000

output:

0

result:

ok 1 number(s): "0"

Test #61:

score: 0
Accepted
time: 0ms
memory: 3720kb

input:

3 2 1000

output:

0

result:

ok 1 number(s): "0"

Test #62:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

4 1 1000

output:

1

result:

ok 1 number(s): "1"

Test #63:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

4 2 1000

output:

1

result:

ok 1 number(s): "1"

Test #64:

score: 0
Accepted
time: 0ms
memory: 3716kb

input:

4 3 1000

output:

0

result:

ok 1 number(s): "0"

Test #65:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

8 3 2

output:

0

result:

ok 1 number(s): "0"

Test #66:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

6 1 100

output:

3

result:

ok 1 number(s): "3"

Test #67:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

6 2 100

output:

2

result:

ok 1 number(s): "2"

Test #68:

score: 0
Accepted
time: 0ms
memory: 3724kb

input:

6 3 100

output:

2

result:

ok 1 number(s): "2"

Test #69:

score: 0
Accepted
time: 2ms
memory: 3796kb

input:

256 128 123981492

output:

1

result:

ok 1 number(s): "1"

Test #70:

score: 0
Accepted
time: 2ms
memory: 3916kb

input:

254 127 1000000000

output:

877

result:

ok 1 number(s): "877"

Test #71:

score: 0
Accepted
time: 170ms
memory: 4656kb

input:

500 14 958912859

output:

650304186

result:

ok 1 number(s): "650304186"

Test #72:

score: 0
Accepted
time: 150ms
memory: 4588kb

input:

500 42 591829519

output:

133671197

result:

ok 1 number(s): "133671197"

Test #73:

score: 0
Accepted
time: 175ms
memory: 4608kb

input:

499 1 999912321

output:

0

result:

ok 1 number(s): "0"

Test #74:

score: 0
Accepted
time: 0ms
memory: 3720kb

input:

499 498 984129849

output:

0

result:

ok 1 number(s): "0"

Test #75:

score: 0
Accepted
time: 179ms
memory: 4740kb

input:

498 1 918239128

output:

604086379

result:

ok 1 number(s): "604086379"

Test #76:

score: 0
Accepted
time: 0ms
memory: 3724kb

input:

498 497 984192849

output:

0

result:

ok 1 number(s): "0"

Test #77:

score: 0
Accepted
time: 5ms
memory: 3924kb

input:

254 127 877

output:

0

result:

ok 1 number(s): "0"

Test #78:

score: 0
Accepted
time: 5ms
memory: 3984kb

input:

254 125 729

output:

0

result:

ok 1 number(s): "0"

Test #79:

score: 0
Accepted
time: 111ms
memory: 4400kb

input:

500 100 613156101

output:

0

result:

ok 1 number(s): "0"

Test #80:

score: 0
Accepted
time: 113ms
memory: 4400kb

input:

500 99 755405164

output:

3

result:

ok 1 number(s): "3"

Test #81:

score: 0
Accepted
time: 111ms
memory: 4468kb

input:

500 99 924361444

output:

924361439

result:

ok 1 number(s): "924361439"

Test #82:

score: 0
Accepted
time: 113ms
memory: 4356kb

input:

500 97 6974800

output:

1

result:

ok 1 number(s): "1"

Test #83:

score: 0
Accepted
time: 114ms
memory: 4416kb

input:

500 96 42601567

output:

42601566

result:

ok 1 number(s): "42601566"

Test #84:

score: 0
Accepted
time: 202ms
memory: 4740kb

input:

500 1 2

output:

1

result:

ok 1 number(s): "1"

Test #85:

score: 0
Accepted
time: 193ms
memory: 4684kb

input:

500 1 5

output:

2

result:

ok 1 number(s): "2"

Test #86:

score: 0
Accepted
time: 196ms
memory: 4736kb

input:

500 1 14

output:

5

result:

ok 1 number(s): "5"

Test #87:

score: 0
Accepted
time: 182ms
memory: 4736kb

input:

500 1 42

output:

33

result:

ok 1 number(s): "33"

Test #88:

score: 0
Accepted
time: 182ms
memory: 4616kb

input:

500 1 132

output:

123

result:

ok 1 number(s): "123"

Test #89:

score: 0
Accepted
time: 181ms
memory: 4608kb

input:

500 1 429

output:

57

result:

ok 1 number(s): "57"

Test #90:

score: 0
Accepted
time: 198ms
memory: 4596kb

input:

500 1 3

output:

0

result:

ok 1 number(s): "0"

Extra Test:

score: 0
Extra Test Passed