問題一覧 > 通常問題

No.3628 Sum of Superfibonacci Numbers

レベル : / AI推定難易度 : 2050 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 14
作問者 : 👑 loop0919 / テスター : ぽえ kazuppa
お気に入りにしたユーザー ProblemId : 13611 / 自分の提出
問題文最終更新日: 2026-08-17 21:47:27
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 509 (順位表) の他の問題:

Problem Statement

A positive integer $n$ is called a good number if $n$ satisfies the following condition.

  • When $n$ is interpreted as a decimal number, let $n_i$ be the value of its $10^i$ place. There exists a non-negative integer $i$ such that $n_{i+2} > n_{i+1} + n_i$.

For a positive integer $n$, define $f(n)$ as the minimum good number greater than or equal to $n$.

You are given a positive integer $N$. Find the value of $f(1) + f(2) + \cdots + f(N)$ modulo $998244353$.

$T$ test cases are given; answer each of them.

Constraints

  • All input values are integers.
  • $1 \leq T \leq 200$
  • $1 \leq N \leq 10^{18}$

Input

The input is given from standard input in the following format.

$T$
$\mathrm{case}_1$
$\mathrm{case}_2$
$\vdots$
$\mathrm{case}_T$

Each test case is given in the following format.

$N$

Output

Output the answers to the test cases in order, separated by newlines.

Sample

Sample 1
Input
4
10
668
169231
1000000000000000000
Output
1000
245820
346334860
992299114

The good numbers in ascending order are $100, 200, 201, 210, 300, 301, 302, 310, 311, 320, 400, \cdots$.

For the $1$-st test case, for every $k = 1, 2, \cdots, 10$, the smallest good number greater than or equal to $k$ is $100$, so the answer is $100 \times 10 = 1000$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。