問題一覧 > 通常問題

No.528 10^9, 10^9+7, and Palindromes

レベル : / AI推定難易度 : 1125 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 65
作問者 : testestest / テスター : Pulmn
お気に入りにしたユーザー ProblemId : 1627 / 自分の提出
問題文最終更新日: 2026-06-25 19:56:47
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 166 (順位表) の他の問題:

Problem Statement

You are given an integer $N$. Find the number of palindromic numbers among the integers between 1 and $N$, inclusive, modulo 10^9 and modulo 10^9+7.

Here, a palindromic number is a number that reads the same from right to left and from left to right, such as "969", "3223", and "1".

Input

N

The input is given as an integer.
$1\leq N\leq10^{100000}$

Output

For the number of palindromic numbers among the integers between 1 and $N$, inclusive,
print the value modulo 10^9 on the first line and the value modulo 10^9+7 on the second line.
Print a newline at the end.

Sample

Sample 1
Input
9
Output
9
9

All of 1 to 9 are palindromic numbers.

Sample 2
Input
99
Output
18
18

The 18 numbers 1,2,…,9,11,22,…,99 are palindromic numbers.

Sample 3
Input
1000000000000000000000000000000
Output
999999998
986000005

There seem to be a lot of palindromic numbers not exceeding 10^30.
As an aside, at about this size it seems possible to recover the actual value using the Chinese Remainder Theorem.

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