結果
問題 | No.491 10^9+1と回文 |
ユーザー |
![]() |
提出日時 | 2023-05-11 12:30:17 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 382 bytes |
コンパイル時間 | 312 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-11-27 11:25:33 |
合計ジャッジ時間 | 6,017 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 WA * 71 |
ソースコード
def f(s): if s == "": return 0 if len(s) == 1: return int(s) a, b = int(s[0]), int(s[-1]) v = a * (pow(10, (len(s) - 1)//2)) if a <= b: v += f(s[1:-1]) v += f(str(10**(len(s) - 1) - 1)) return v N = int(input()) ten = 10 ** 9 if N < ten + 1: print(0) exit() a, b = N // ten, N % ten if a > b: a -= 1 print(f(str(a)))