結果
問題 |
No.491 10^9+1と回文
|
ユーザー |
|
提出日時 | 2021-11-20 04:37:40 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 872 bytes |
コンパイル時間 | 352 ms |
コンパイル使用メモリ | 11,904 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2025-01-02 12:51:18 |
合計ジャッジ時間 | 5,953 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 100 WA * 3 |
ソースコード
#!/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 = """588558855558855885 # """ # 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 <= N1 or (b == N1 and b <= N2): ans += 1 return ans N = int(input()) print(solve(N))