結果
問題 |
No.491 10^9+1と回文
|
ユーザー |
|
提出日時 | 2017-03-11 00:33:57 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 759 bytes |
コンパイル時間 | 176 ms |
コンパイル使用メモリ | 82,184 KB |
実行使用メモリ | 75,900 KB |
最終ジャッジ日時 | 2024-06-24 09:18:56 |
合計ジャッジ時間 | 8,901 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 WA * 57 MLE * 12 |
ソースコード
import sys def solve(): N = int(input()) M = N // (10**9 + 1) ans = 0 k = [0, 9, 9, 90, 90, 900, 900, 9000, 9000, 90000] d = 1 while 10**d <= M: ans += k[d] d += 1 d -= 1 e = 1 while 10**d * e <= M: ans += max(1, k[max(0, d - 2)]) e += 1 e -= 1 if d - 2 >= 0: uni = 10**d + 1 f = 0 while uni*e + f*10 <= M: fs = str(f).zfill(d - 2) if(fs == reversed(fs)): ans += 1 f += 1 print(ans) def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None if __name__ == '__main__': solve()