結果
| 問題 |
No.491 10^9+1と回文
|
| コンテスト | |
| ユーザー |
ayaoni
|
| 提出日時 | 2020-12-13 04:27:47 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 1,000 ms |
| コード長 | 928 bytes |
| コンパイル時間 | 285 ms |
| コンパイル使用メモリ | 82,204 KB |
| 実行使用メモリ | 53,972 KB |
| 最終ジャッジ日時 | 2024-09-19 22:50:37 |
| 合計ジャッジ時間 | 6,251 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 103 |
ソースコード
import sys
from itertools import accumulate
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())
N = I()
M = N//(10**9+1)
# M以下の正の整数の中で、回文が何個あるかを答えれば良い
if M == 0:
print(0)
exit()
X = [0,9,9,90,90,900,900,9000,9000]
AX = list(accumulate(X))
# AX[i] = i桁以下の回文の個数
d = len(str(M)) # Mの桁数
ans = AX[d-1]
B = M//(10**(d//2))
ans += B-10**((d-1)//2)
C = str(B)
for i in range(d//2-1,-1,-1):
C += str(C[i])
C = int(C)
if C <= M:
ans += 1
print(ans)
ayaoni