結果

問題 No.2385 Parse Integer with Radix
ユーザー RuteRute
提出日時 2023-07-21 21:59:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 644 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 81,748 KB
実行使用メモリ 59,672 KB
最終ジャッジ日時 2023-10-21 22:00:51
合計ジャッジ時間 1,320 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

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)
        
0