結果

問題 No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
ユーザー ygd.ygd.
提出日時 2021-11-07 12:46:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 933 bytes
コンパイル時間 466 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 75,640 KB
最終ジャッジ日時 2023-08-08 17:58:21
合計ジャッジ時間 3,252 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,200 KB
testcase_01 AC 71 ms
71,196 KB
testcase_02 AC 72 ms
71,260 KB
testcase_03 AC 70 ms
71,092 KB
testcase_04 AC 71 ms
71,348 KB
testcase_05 AC 71 ms
71,432 KB
testcase_06 AC 70 ms
71,396 KB
testcase_07 AC 72 ms
71,220 KB
testcase_08 AC 76 ms
75,324 KB
testcase_09 AC 78 ms
75,396 KB
testcase_10 AC 76 ms
75,476 KB
testcase_11 AC 71 ms
70,884 KB
testcase_12 AC 74 ms
75,640 KB
testcase_13 AC 75 ms
75,328 KB
testcase_14 AC 71 ms
71,280 KB
testcase_15 AC 70 ms
71,156 KB
testcase_16 AC 75 ms
75,396 KB
testcase_17 AC 75 ms
75,400 KB
testcase_18 AC 76 ms
75,468 KB
testcase_19 AC 72 ms
71,280 KB
testcase_20 AC 74 ms
71,088 KB
testcase_21 AC 73 ms
71,196 KB
testcase_22 AC 72 ms
71,096 KB
testcase_23 AC 72 ms
71,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline

def chr_to_int(x):
    if x == 'A': return 10
    if x == 'B': return 11
    if x == 'C': return 12
    if x == 'D': return 13
    if x == 'E': return 14
    if x == 'F': return 15
    return int(x)


def main():
    S = str(input()); N = len(S)
    MAX = 500
    L = [0]*MAX
    dif = 1
    for i in range(N):
        keta = i
        val = dif*chr_to_int(S[N-1-i]) #下から
        while val > 0:
            val += L[MAX-1-keta]
            L[MAX-1-keta] = val%8
            val //= 8
            keta += 1
        dif *= 2
    #print(L)
    cnt = [0]*9
    Flag = True
    for x in L:
        if Flag and x == 0: continue
        Flag = False #初めて0以外が来た
        cnt[x] += 1
    mx = max(cnt)
    ans = []
    for i in range(1,9):
        if cnt[i] == mx:
            ans.append(i)
    print(*ans)


if __name__ == '__main__':
    main()
0