結果
問題 |
No.491 10^9+1と回文
|
ユーザー |
|
提出日時 | 2021-11-20 04:34:37 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 837 bytes |
コンパイル時間 | 366 ms |
コンパイル使用メモリ | 82,016 KB |
実行使用メモリ | 87,580 KB |
最終ジャッジ日時 | 2025-01-02 12:39:27 |
合計ジャッジ時間 | 15,474 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | MLE * 3 |
other | MLE * 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 <= N2: ans += 1 return ans N = int(input()) print(solve(N))