結果

問題 No.491 10^9+1と回文
ユーザー 6soukiti29
提出日時 2017-03-21 22:31:01
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 900 bytes
コンパイル時間 117 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-05 06:10:09
合計ジャッジ時間 5,302 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 89 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

def kaibun(y):
x = len(str(y))
X = [9,9]
i = 2
while x > i:
if i % 2 == 0:
X.append(X[i - 1] * 10)
else:
X.append(X[i - 1])
i = i + 1
a = sum(X[:x - 1])
for j in range(1, x // 2 + 1):
if j == 1:
a = a + (int(str(y)[j - 1]) - 1) * X[x - 2 * j + 1]//9
else:
a = a + (int(str(y)[j - 1])) * X[x - 2 * j + 1] // 9
if str(y)[:x//2][::-1] and str(y)[x//2 + 1:] and int(str(y)[:x//2][::-1]) < int(str(y)[x//2:]) and x % 2 == 0:
a = a + 1
elif x % 2 == 1:
a = a + int(str(y)[x//2])
if str(y)[:x//2][::-1] and str(y)[x//2 + 1:] and int(str(y)[:x//2][::-1]) < int(str(y)[x//2 + 1:]):
a = a + 1
if x == 1:
return y
return a
# X[i] i
n = input()
if len(n) < 10:
print(0)
else:
ni = n[:-9]
k = int(ni)
answer = kaibun(k)
if len(n) == 10 and int(n) % 10**9 < int(n[0]):
answer = answer - 1
print(answer)
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0