結果

問題 No.2385 Parse Integer with Radix
ユーザー RuteRute
提出日時 2023-07-21 22:00:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 671 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 81,592 KB
実行使用メモリ 59,580 KB
最終ジャッジ日時 2023-10-21 22:01:34
合計ジャッジ時間 1,695 ms
ジャッジサーバーID
(参考情報)
judge10 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
53,404 KB
testcase_01 AC 48 ms
59,580 KB
testcase_02 AC 49 ms
59,580 KB
testcase_03 AC 48 ms
59,580 KB
testcase_04 AC 52 ms
59,580 KB
testcase_05 AC 44 ms
53,404 KB
testcase_06 AC 42 ms
53,404 KB
testcase_07 AC 43 ms
53,404 KB
testcase_08 AC 43 ms
53,404 KB
testcase_09 AC 43 ms
53,404 KB
testcase_10 AC 44 ms
53,404 KB
testcase_11 AC 46 ms
53,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Q = int(input())
P = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"]
def make_2(s):
    now = 0
    for j in range(2, len(s)):
        now += P.index(s[j]) * (2 ** (len(s) - j - 1))
    print(now)
def make_8(s):
    now = 0
    for j in range(2,len(s)):
        now += P.index(s[j]) * (8 ** (len(s) - j - 1))
    print(now)
def make_16(s):
    now = 0
    for j in range(2, len(s)):
        now += P.index(s[j]) * (16 ** (len(s) - j - 1))
    print(now)
while Q:
    Q -= 1
    S = input()
    if S[0:2] == "0b":
        make_2(S)
    elif S[0:2] == "0o":
        make_8(S)
    elif S[0:2] == "0x":
        make_16(S)
    else:
        print(S)
        
0