QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#820364#9878. A xor B plus CHuTaoWA 772ms38560kbC++141.5kb2024-12-18 21:09:462024-12-18 21:09:51

Judging History

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

  • [2024-12-18 21:09:51]
  • 评测
  • 测评结果:WA
  • 用时:772ms
  • 内存:38560kb
  • [2024-12-18 21:09:46]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

const int N = 6e6 + 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];

    LL s = 1 << (Block + 1);
    for(int i = Block + 1; i <= 76; 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 += s * x;
        T = min(T * 2, n + 1);
        m = mm;
        for(int i = 1; i <= m; i ++ ) y[i] = yy[i];
    }

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

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 14116kb

input:

1 2 3 4

output:

7

result:

ok "7"

Test #2:

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

input:

123 456 789 123456789

output:

567982455

result:

ok "567982455"

Test #3:

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

input:

0 0 0 1000000000000000000

output:

0

result:

ok "0"

Test #4:

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

input:

628 314 157 1

output:

628

result:

ok "628"

Test #5:

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

input:

167 924 167 2

output:

924

result:

ok "924"

Test #6:

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

input:

1048575 1048575 1048575 1000000000000000000

output:

1048575

result:

ok "1048575"

Test #7:

score: -100
Wrong Answer
time: 772ms
memory: 38560kb

input:

287144 758614 992207 1000000000000000000

output:

660160431

result:

wrong answer 1st words differ - expected: '638555367', found: '660160431'