結果
| 問題 |
No.327 アルファベット列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-06 03:57:37 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 2,000 ms |
| コード長 | 506 bytes |
| コンパイル時間 | 270 ms |
| コンパイル使用メモリ | 82,400 KB |
| 実行使用メモリ | 54,220 KB |
| 最終ジャッジ日時 | 2024-11-23 15:23:36 |
| 合計ジャッジ時間 | 3,861 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
ソースコード
from bisect import bisect_right
n = int(input())
N = [0]
for i in range(1, 11):
N.append(N[-1] + pow(26, i))
ANS = ['' for _ in range(11)]
f = True
while True:
idx = bisect_right(N, n) - 1
if idx == 0:
ANS[10 - idx] = chr(ord('A') + n)
break
res = n - N[idx]
r = res // pow(26, idx)
ANS[10 - idx] = chr(ord('A') + r)
if f:
for i in range(10 - idx + 1, 11):
ANS[i] = 'A'
f = False
n -= (r + 1) * pow(26, idx)
print(''.join(ANS))