結果

問題 No.327 アルファベット列
ユーザー FromBooskaFromBooska
提出日時 2023-02-24 19:45:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 1,365 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 71,512 KB
最終ジャッジ日時 2023-10-11 04:33:10
合計ジャッジ時間 6,853 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,328 KB
testcase_01 AC 72 ms
71,272 KB
testcase_02 AC 70 ms
71,412 KB
testcase_03 AC 70 ms
71,512 KB
testcase_04 AC 76 ms
71,372 KB
testcase_05 AC 72 ms
71,168 KB
testcase_06 AC 74 ms
70,976 KB
testcase_07 AC 72 ms
71,332 KB
testcase_08 AC 72 ms
71,260 KB
testcase_09 AC 71 ms
71,364 KB
testcase_10 AC 72 ms
71,352 KB
testcase_11 AC 73 ms
71,104 KB
testcase_12 AC 71 ms
71,132 KB
testcase_13 AC 73 ms
71,164 KB
testcase_14 AC 73 ms
71,372 KB
testcase_15 AC 73 ms
71,420 KB
testcase_16 AC 74 ms
71,268 KB
testcase_17 AC 73 ms
71,416 KB
testcase_18 AC 77 ms
71,168 KB
testcase_19 AC 76 ms
71,256 KB
testcase_20 AC 76 ms
71,312 KB
testcase_21 AC 77 ms
71,420 KB
testcase_22 AC 74 ms
71,268 KB
testcase_23 AC 73 ms
71,260 KB
testcase_24 AC 73 ms
71,284 KB
testcase_25 AC 73 ms
71,488 KB
testcase_26 AC 72 ms
71,164 KB
testcase_27 AC 73 ms
71,112 KB
testcase_28 AC 71 ms
71,168 KB
testcase_29 AC 73 ms
71,276 KB
testcase_30 AC 72 ms
71,312 KB
testcase_31 AC 71 ms
71,172 KB
testcase_32 AC 71 ms
71,408 KB
testcase_33 AC 71 ms
71,468 KB
testcase_34 AC 73 ms
71,104 KB
testcase_35 AC 71 ms
71,484 KB
testcase_36 AC 72 ms
71,136 KB
testcase_37 AC 72 ms
71,164 KB
testcase_38 AC 71 ms
71,316 KB
testcase_39 AC 73 ms
71,324 KB
testcase_40 AC 74 ms
71,312 KB
testcase_41 AC 71 ms
70,976 KB
testcase_42 AC 71 ms
71,416 KB
testcase_43 AC 72 ms
71,416 KB
testcase_44 AC 71 ms
71,216 KB
testcase_45 AC 71 ms
71,212 KB
testcase_46 AC 72 ms
71,464 KB
testcase_47 AC 72 ms
71,316 KB
testcase_48 AC 71 ms
71,328 KB
testcase_49 AC 72 ms
71,264 KB
testcase_50 AC 72 ms
71,016 KB
testcase_51 AC 72 ms
71,460 KB
testcase_52 AC 72 ms
71,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 数字Nを26進数に直せばいいと思ったがうまくいかない
# 簡単と思って超苦しんだ
# まず26進数として何桁になるのかを調べる、それがd_count+1
# たとえば26は26以上なのでd_count=1であり2桁
# この26進数を書くと以下のようになる
# 0=A,,,,25=Z
# 26**1*1+0=AA,,,,26*25+25=ZZ
# 26**2*1+0=AAA,,,
# https://yukicoder.me/problems/no/327/editorial
# たとえばN=10000のとき
# 10000>=26なので26を引く(1桁の数字の分)、9974>=26**2なので26**2を引いて(2桁の数字の分)9298
# この9298を26**2の桁、26**1の桁、26**0の桁に分解すると
# 9298=26**2*13 (N) + 26**1*19 (T) + 26**0*16 (Q) = NTQ

N = int(input())
N_remainder = N
alphabets = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
d_count = 0
# まず桁数を調べる
# そしてその桁数までの数を引く、たとえば3桁なら1桁の分と2桁の分
# この引き算が重要

for i in range(10): 
    # 26**10 > 10**12
    if N_remainder >= 26**(d_count+1):
        N_remainder -= 26**(d_count+1)
        d_count += 1
    else:
        break
#print('d_count', d_count, 'N_remainder', N_remainder)
    
ans_list = []
for i in range(d_count+1):
    num = N_remainder//(26**(d_count-i))
    ans_list.append(alphabets[num])
    N_remainder -= num*(26**(d_count-i))
#print(ans_list)

ans = ''.join(ans_list)
print(ans)
0