#P11957. 「ZHQOI R1」幂和

    ID: 11753 远端评测题 3000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>数学O2优化快速数论变换 NTT洛谷比赛

「ZHQOI R1」幂和

Description

Given integers n,x,k n, x, k , compute the value of the following expression:

i=0n(1)popcnt(i)(i+x)k\sum_{i=0}^n (-1)^{\text{popcnt}(i)} (i + x)^k

where the result is taken modulo 998244353 998244353 .

Special Note: 00 0^0 is defined as 1 1 .

Here, popcnt(x) \text{popcnt}(x) denotes the number of 11's in the binary representation of x x .

Input Format

A single line containing three integers n,x,k n, x, k .

Output Format

Output a single integer representing the answer.

5 5 2
23
12345678 1919810 11451
69157901
999999999999 125432670 1000
154496571

Hint

Constraints

This problem uses subtask scoring.

For all test cases:

  • 0n1012 0 \leq n \leq 10^{12} ,
  • 0x109 0 \leq x \leq 10^9 ,
  • 0k105 0 \leq k \leq 10^5 .
Subtask n n \leq k k \leq Score
1 106 10^6 105 10^5 7 7
2 108 10^8 8 8
3 1012 10^{12} 0 0 5 5
4 1 1 10 10
5 2 2
6 100 100
7 103 10^3 15 15
8 104 10^4
9 105 10^5 20 20