結果
| 問題 |
No.3055 Simple Chicken Game
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:35:24 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 642 bytes |
| コンパイル時間 | 184 ms |
| コンパイル使用メモリ | 82,976 KB |
| 実行使用メモリ | 67,524 KB |
| 最終ジャッジ日時 | 2025-03-31 17:36:25 |
| 合計ジャッジ時間 | 3,087 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 2 |
| other | RE * 30 |
ソースコード
n = input().strip()
k = len(n)
ans = 0
# Count palindromes for all lengths shorter than k
for i in range(1, k):
ans += 9 * (10 ** ((i - 1) // 2))
m = (k + 1) // 2 # ceil(k/2)
prefix = n[:m]
# Construct the palindrome from the prefix
if k % 2 == 0:
constructed = prefix + prefix[::-1]
else:
constructed = prefix + prefix[:-1][::-1]
# Determine the maximum valid prefix
if int(constructed) > int(n):
max_p = int(prefix) - 1
else:
max_p = int(prefix)
min_p = 10 ** (m - 1)
# Calculate the count of valid prefixes and add to the answer
count = max(0, max_p - min_p + 1) if max_p >= min_p else 0
ans += count
print(ans)
lam6er