luogu#P3791. 普通数学题

    ID: 2747 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>洛谷原创O2优化枚举进制前缀和洛谷月赛

普通数学题

Background

One day, zzq had no problems to set. So he casually wrote an expression to compute $\sum_{i=0}^n \sum_{j=0}^m i \operatorname{xor} j \operatorname{xor} x$, where xor\operatorname{xor} denotes bitwise XOR.

zzy thought this was easy, so he casually added a function: $\sum_{i=0}^n \sum_{j=0}^m d(i \operatorname{xor} j \operatorname{xor} x)$, where xor\operatorname{xor} denotes bitwise XOR and d(x)d(x) denotes the number of divisors of xx. Note that d(0)=0d(0) = 0.

Now zzq could not solve it, so he wrote a brute-force generator to produce testdata and threw this problem to you.

Problem Description

Given three integers n,m,xn, m, x, compute $\sum_{i=0}^n \sum_{j=0}^m d(i \operatorname{xor} j \operatorname{xor} x)$, where xor\operatorname{xor} denotes bitwise XOR and d(x)d(x) denotes the number of divisors of xx.

Since the answer can be large, output the result modulo 998244353998244353.

Input Format

One line with three integers n,m,xn, m, x.

Output Format

Output the answer modulo 998244353998244353.

0 2 233
14
123 234 345
205761

Hint

For 20%20\% of the testdata, n,m,x2000n, m, x \leq 2000.

For 50%50\% of the testdata, n,m,x106n, m, x \leq 10^6.

For 80%80\% of the testdata, n,m,x108n, m, x \leq 10^8.

For 100%100\% of the testdata, 1n,m,x10101 \leq n, m, x \leq 10^{10}.

Translated by ChatGPT 5