結果

問題 No.491 10^9+1と回文
ユーザー 👑 rin204
提出日時 2022-04-16 18:17:08
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 556 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-12-25 21:58:48
合計ジャッジ時間 9,294 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 102 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

n = input().zfill(18)
if len(n) == 19:
    n = "9" * 18
S = n[:9]
T = n[9:]
S = int(S)
T = int(T)
if T >= S:
    n = S
else:
    n = S - 1

ans = min(n, 9)
x = 1
while 1:
    br = False
    for i in range(x, 10 * x):
        i = str(i)
        z = i + i[::-1]
        if int(z) <= n:
            ans += 1
        else:
            br = True
        for j in range(10):
            z = i + str(j) + i[::-1]
            if int(z) <= n:
                ans += 1
            else:
                br = True
    x *= 10
    if br:
        break

print(ans)
    
0