結果
| 問題 |
No.491 10^9+1と回文
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-20 04:38:36 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 1,000 ms |
| コード長 | 861 bytes |
| コンパイル時間 | 390 ms |
| コンパイル使用メモリ | 12,032 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2025-01-02 12:53:21 |
| 合計ジャッジ時間 | 6,190 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 103 |
ソースコード
#!/usr/bin/env python3
# from typing import *
import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq
def input():
return sys.stdin.readline()[:-1]
# sys.setrecursionlimit(1000000)
# _INPUT = """4000000000
# """
# sys.stdin = io.StringIO(_INPUT)
INF = 10**10
MOD = 1000000007
def solve(N):
if N < 10**9+1:
return 0
N1 = N // (10**9)
N2 = N % (10**9)
d = len(str(N1))
ans = 0
for d1 in range(1, d):
i = (d1+1)//2 - 1
ans += 9 * (10 ** i)
a = N1 // (10**(d//2))
ans += int(str(int(str(a)[0])-1) + str(a)[1:])
if d % 2 == 0:
b = int(str(a) + str(a)[::-1])
else:
b = int(str(a) + str(a)[:-1][::-1])
if b < N1 or (b == N1 and b <= N2):
ans += 1
return ans
N = int(input())
print(solve(N))