結果
| 問題 | No.491 10^9+1と回文 | 
| コンテスト | |
| ユーザー |  rlangevin | 
| 提出日時 | 2023-05-18 08:54:37 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 175 ms / 1,000 ms | 
| コード長 | 508 bytes | 
| コンパイル時間 | 126 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 10,880 KB | 
| 最終ジャッジ日時 | 2024-12-16 01:14:39 | 
| 合計ジャッジ時間 | 7,370 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 103 | 
ソースコード
N = int(input())
ten = 10 ** 9
if N < ten + 1:
    print(0)
    exit()
a, b = N // ten, N % ten
if a > b:
    a -= 1
ans = 0
M = 10**5 + 5
for i in range(1, M):
    s = str(i)
    n = int(s + s[::-1])
    
    if n <= a:
        ans += 1
    else:
        break
for m in range(10):
    for i in range(M):
        if i == 0:
            s = ""
        else:
            s = str(i)
        n = int(s + str(m) + s[::-1])
        if n <= a:
            ans += 1
        else:
            break
print(ans - 1)
            
            
            
        