102382: [AtCoder]ABC238 C - digitnum

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $300$ points

Problem Statement

Given an integer $N$, solve the following problem.

Let $f(x)=$ (The number of positive integers at most $x$ with the same number of digits as $x$).
Find $f(1)+f(2)+\dots+f(N)$ modulo $998244353$.

Constraints

  • $N$ is an integer.
  • $1 \le N < 10^{18}$

Input

Input is given from Standard Input in the following format:

$N$

Output

Print the answer as an integer.


Sample Input 1

16

Sample Output 1

73
  • For a positive integer $x$ between $1$ and $9$, the positive integers at most $x$ with the same number of digits as $x$ are $1,2,\dots,x$.
    • Thus, we have $f(1)=1,f(2)=2,...,f(9)=9$.
  • For a positive integer $x$ between $10$ and $16$, the positive integers at most $x$ with the same number of digits as $x$ are $10,11,\dots,x$.
    • Thus, we have $f(10)=1,f(11)=2,...,f(16)=7$.

The final answer is $73$.


Sample Input 2

238

Sample Output 2

13870

Sample Input 3

999999999999999999

Sample Output 3

762062362

Be sure to find the sum modulo $998244353$.

Input

题意翻译

### 题目描述 定义 $f(x)$ 为不大于 $x$ 且位数与 $x$ 相同的正整数的个数。 给定 $N$,求 $\sum\limits_{i=1}^Nf(i)\bmod 998244353$。 ### 输入格式 一行一个整数 $N$。 ### 输出格式 一行一个整数,代表结果。 ### 数据范围与提示 对于 $100\%$ 的数据,$1\leq N<10^{18}$。 样例 #1 解释: - 对于 $1\leq x\leq 9$,$f(x)=x$。 - 对于 $10\leq x\leq 16$,$f(x)=x-9$。 综上,和为 $73$。

Output

得分:300分 部分 问题描述 给定一个整数$N$,解决以下问题。 令$f(x)=$(数字$x$的位数与$x$本身相同的正整数的数量)。 找到$f(1)+f(2)+\dots+f(N)$对$998244353$取模的结果。 部分 约束 *$N$是一个整数。 *$1 \le N < 10^{18}$ 部分 输入 输入以以下格式从标准输入给出: $N$ 部分 输出 将答案作为整数打印。 部分 样例输入1 16 部分 样例输出1 73 *对于介于1和9之间的正整数$x$,数字$x$的位数与$x$本身相同的正整数是$1,2,\dots,x$。 *对于介于10和16之间的正整数$x$,数字$x$的位数与$x$本身相同的正整数是$10,11,\dots,x$。 最终答案是73。 部分 样例输入2 238 部分 样例输出2 13870 部分 样例输入3 999999999999999999 部分 样例输出3 762062362 确保找到对$998244353$取模的结果。

加入题单

算法标签: