QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#820356#9878. A xor B plus CHuTaoAC ✓794ms39832kbC++142.1kb2024-12-18 21:06:142024-12-18 21:06:19

Judging History

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

  • [2024-12-18 21:06:19]
  • 评测
  • 测评结果:AC
  • 用时:794ms
  • 内存:39832kb
  • [2024-12-18 21:06:14]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

const int N = 1e7 + 5, Block = 19, P = 998244353;

int A, B, C;
LL n;
int x00[N];
int *x0 = x00 + 2;
LL y[N], yy[N];

int main()
{
    scanf("%d%d%d%lld", &A, &B, &C, &n);
    if(n == 1) return printf("%d\n", A), 0;
    if(n == 2) return printf("%d\n", B), 0;
    n -= 3;
    LL T = 3 << Block;
    LL ans = 0;

    int m = 0;
    x0[-2] = A, x0[-1] = B;
    for(int i = -2; i < T - 2; i ++ )
    {
        x0[i + 2] = ((x0[i] ^ x0[i + 1]) + C) & ((1 << (Block + 1)) - 1);
        if((x0[i] ^ x0[i + 1]) + C >= (1 << (Block + 1))) y[ ++ m] = i + 2;
    }
    ans = x0[n % T];

    // memset(x00, 0, sizeof x00);
    // for(int i = 1; i <= m; i ++ )
    // {
    //     int j = i;
    //     for(int i = y[j]; i < T * 2; i += 3) x0[i] ^= 1;
    //     for(int i = y[j] + 1; i < T * 2; i += 3) x0[i] ^= 1;
    //     for(int i = y[j] + T; i < T * 2; i += 3) x0[i] ^= 1;
    //     for(int i = y[j] + T + 1; i < T * 2; i += 3) x0[i] ^= 1;
    // }
    // for(int i = 0; i < T * 2; i ++ ) printf("%d", x0[i]);
    // puts("");

    LL s = 1 << (Block + 1);
    for(int i = Block + 1; i <= 80; i ++ , s = s * 2 % P)
    {
        int mm = 0;
        x0[0] = x0[1] = x0[2] = 0;
        int x = -1;
        LL p = n % (T * 2);
        for(int i = 1; i <= m; i ++ )
        {
            if(y[i] > p && x == -1) x = x0[p % 3];
            if(x0[(y[i] + 1) % 3] ^= 1, !(x0[y[i] % 3] ^= 1))
                yy[ ++ mm] = y[i];
        }
        for(int i = 1; i <= m && y[i] + T <= n; i ++ )
        {
            if(y[i] + T > p && x == -1) x = x0[p % 3];
            if(x0[(y[i] + 1) % 3] ^= 1, !(x0[y[i] % 3] ^= 1))
                yy[ ++ mm] = y[i] + T;
        }
        if(x == -1) x = x0[p % 3];
        ans = (ans + s * x) % P;
        // printf("%d", x);
        T = min(T * 2, n + 1);
        m = mm;
        for(int i = 1; i <= m; i ++ ) y[i] = yy[i];

        // printf("#%d %d\n", i, m);
        // for(int i = 1; i <= m; i ++ ) printf("%lld ", y[i]);
        // puts("");
    }

    printf("%lld\n", ans);
    return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1 2 3 4

output:

7

result:

ok "7"

Test #2:

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

input:

123 456 789 123456789

output:

567982455

result:

ok "567982455"

Test #3:

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

input:

0 0 0 1000000000000000000

output:

0

result:

ok "0"

Test #4:

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

input:

628 314 157 1

output:

628

result:

ok "628"

Test #5:

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

input:

167 924 167 2

output:

924

result:

ok "924"

Test #6:

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

input:

1048575 1048575 1048575 1000000000000000000

output:

1048575

result:

ok "1048575"

Test #7:

score: 0
Accepted
time: 793ms
memory: 36644kb

input:

287144 758614 992207 1000000000000000000

output:

638555367

result:

ok "638555367"

Test #8:

score: 0
Accepted
time: 755ms
memory: 36212kb

input:

442510 534717 936857 1000000000000000000

output:

125005501

result:

ok "125005501"

Test #9:

score: 0
Accepted
time: 792ms
memory: 39832kb

input:

507590 985947 1025549 999999999999999833

output:

363289377

result:

ok "363289377"

Test #10:

score: 0
Accepted
time: 794ms
memory: 39404kb

input:

989414 986755 1024915 1000000000000000000

output:

176552525

result:

ok "176552525"

Test #11:

score: 0
Accepted
time: 611ms
memory: 31900kb

input:

773910 981383 748815 999999999999999372

output:

712048477

result:

ok "712048477"

Test #12:

score: 0
Accepted
time: 429ms
memory: 28304kb

input:

539000 982202 549877 1000000000000000000

output:

49295427

result:

ok "49295427"

Test #13:

score: 0
Accepted
time: 616ms
memory: 33828kb

input:

930318 901108 790115 999999999999999002

output:

446688556

result:

ok "446688556"

Test #14:

score: 0
Accepted
time: 779ms
memory: 36664kb

input:

57298 210381 985237 1000000000000000000

output:

533555472

result:

ok "533555472"

Test #15:

score: 0
Accepted
time: 232ms
memory: 22584kb

input:

567956 1013479 284068 1000000000000000000

output:

13855344

result:

ok "13855344"

Test #16:

score: 0
Accepted
time: 781ms
memory: 39764kb

input:

694266 795841 967344 1000000000000000000

output:

179712105

result:

ok "179712105"

Test #17:

score: 0
Accepted
time: 192ms
memory: 22676kb

input:

744515 402386 261828 1000000000000000000

output:

915814204

result:

ok "915814204"

Test #18:

score: 0
Accepted
time: 87ms
memory: 15316kb

input:

630928 108751 103226 1000000000000000000

output:

314920156

result:

ok "314920156"

Test #19:

score: 0
Accepted
time: 459ms
memory: 27400kb

input:

408870 219543 576432 1000000000000000000

output:

332612604

result:

ok "332612604"

Test #20:

score: 0
Accepted
time: 781ms
memory: 39364kb

input:

208613 769277 1010542 819875140559301752

output:

110220300

result:

ok "110220300"

Test #21:

score: 0
Accepted
time: 299ms
memory: 24916kb

input:

123844 719656 377241 520974001002628387

output:

986512272

result:

ok "986512272"

Test #22:

score: 0
Accepted
time: 662ms
memory: 34488kb

input:

774205 820111 841396 711066335916901718

output:

254873758

result:

ok "254873758"

Test #23:

score: 0
Accepted
time: 762ms
memory: 36380kb

input:

604531 395365 966071 999594448264125858

output:

505142123

result:

ok "505142123"

Test #24:

score: 0
Accepted
time: 719ms
memory: 36684kb

input:

59523 598376 922420 752304351201620672

output:

351022203

result:

ok "351022203"

Test #25:

score: 0
Accepted
time: 742ms
memory: 37012kb

input:

192450 176925 1037973 192583019203393748

output:

56600397

result:

ok "56600397"

Test #26:

score: 0
Accepted
time: 754ms
memory: 36492kb

input:

972801 523798 994144 594688603126478507

output:

750534499

result:

ok "750534499"

Test #27:

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

input:

669131 939565 629 543390474884493567

output:

652889135

result:

ok "652889135"

Test #28:

score: 0
Accepted
time: 305ms
memory: 23368kb

input:

829091 688584 371532 935387048229453232

output:

784327643

result:

ok "784327643"

Test #29:

score: 0
Accepted
time: 124ms
memory: 16280kb

input:

407113 311573 150840 428344291461283594

output:

486756568

result:

ok "486756568"

Test #30:

score: 0
Accepted
time: 219ms
memory: 23040kb

input:

338931 949581 280744 289664704872449795

output:

459928211

result:

ok "459928211"

Test #31:

score: 0
Accepted
time: 326ms
memory: 23648kb

input:

16277 434162 426083 575309380820099707

output:

927534514

result:

ok "927534514"

Test #32:

score: 0
Accepted
time: 424ms
memory: 27248kb

input:

669467 627218 559817 371026815047584891

output:

393999810

result:

ok "393999810"

Test #33:

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

input:

256940 648067 248598 702551234623621497

output:

107167397

result:

ok "107167397"

Test #34:

score: 0
Accepted
time: 69ms
memory: 20272kb

input:

112359 956967 160416 704822623170226832

output:

945781095

result:

ok "945781095"

Test #35:

score: 0
Accepted
time: 709ms
memory: 35612kb

input:

608294 272679 879126 922348606336628938

output:

508826865

result:

ok "508826865"

Test #36:

score: 0
Accepted
time: 310ms
memory: 23948kb

input:

844223 856121 402112 640219260480538711

output:

494733011

result:

ok "494733011"

Test #37:

score: 0
Accepted
time: 75ms
memory: 18816kb

input:

589375 991964 85955 471255438930064341

output:

591777452

result:

ok "591777452"

Test #38:

score: 0
Accepted
time: 391ms
memory: 27984kb

input:

613807 685977 493404 774205724944088968

output:

686401274

result:

ok "686401274"

Test #39:

score: 0
Accepted
time: 42ms
memory: 16136kb

input:

686801 458561 52258 593361261434725536

output:

197205169

result:

ok "197205169"

Extra Test:

score: 0
Extra Test Passed