No.3304 INCREASE decrease
Problem Statement
For positive integers $X, Y, Z$ satisfying $X < Y < Z < N$, let $x, y, z$ denote their last $K$ digits, respectively. Find the number of triples $X, Y, Z$ satisfying all of the following conditions.
- $0 < Y - X = Z - Y$
- $0 < x - y = y - z$
You are given $T$ test cases; find the answer for each of them.
Constraints
- All input values are integers
- $10 \leq N \leq 10^{18}$
- $1 \leq K$
- $10^K \leq N$
- $1 \leq T \leq 10^5$
Input
The input is given from Standard Input in the following format.$T$
$\text{case}_1$
$\vdots$
$\text{case}_T$
Each test case is given in the following format.
$N \ K$
Output
Output the answer modulo $998244353$.
Sample
Sample 1
Input
3 21 1 2025 2 123456789012345678 9
Output
4 231310 889386892
For example, in the case $(N, K) = (21, 1)$, the triples $(X, Y, Z)$ satisfying the conditions are the $4$ triples $(2, 11, 20), (4, 12, 20), (6, 13, 20), (8, 14, 20)$. Considering $(2, 11, 20)$, we have $(X, Y, Z) = (2, 11, 20), (x, y, z) = (2, 1, 0)$, which satisfies $0 < 9 = 11 - 2 = 20 - 11$ and $0 < 1 = 2 - 1 = 1 - 0$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
sepa38