#P11009. 『STA - R7』求和

『STA - R7』求和

Problem Description

Lloyd has a positive integer tt, with the initial value t=2t=2 or t=3t=3. Each time, he can increase tt by 2t2^t or by log2(t1)\lfloor\log_2(t-1)\rfloor.

Let f(x)f(x) be the minimum number of operations needed to obtain t=xt=x. If xx cannot be obtained by operations, then f(x)=0f(x)=0.

Now you are given a positive integer nn. You need to compute i=1nf(i)\sum_{i=1}^n f(i). The answer may be very large, so output it modulo 998244353998244353.

Input Format

This problem has multiple test cases.

The first line contains a positive integer TT, representing the number of test cases.

The next TT lines each contain a positive integer nn, describing one query.

Output Format

Output TT lines, one for each query. Print the answer modulo 998244353998244353.

7
1
10
1000000
10000000
1000000000
1000000000000
1000000000000000000

0
16
922782102
752337093
360487662
955916859
689020696

Hint

Constraints:

  • Subtask 1 (10 pts): n107n\le 10^7.
  • Subtask 2 (30 pts): T=1T=1.
  • Subtask 3 (30 pts): n240n\le2^{40}.
  • Subtask 4 (30 pts): No special constraints.

For all testdata, 1T1041\le T\le 10^4, 1n2601\le n\le2^{60}.

Translated by ChatGPT 5