結果

問題 No.2385 Parse Integer with Radix
ユーザー mattu34mattu34
提出日時 2023-07-28 20:44:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 705 bytes
コンパイル時間 394 ms
コンパイル使用メモリ 82,788 KB
実行使用メモリ 60,004 KB
最終ジャッジ日時 2024-04-16 04:30:32
合計ジャッジ時間 1,597 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,096 KB
testcase_01 AC 49 ms
59,776 KB
testcase_02 AC 47 ms
59,648 KB
testcase_03 AC 48 ms
60,004 KB
testcase_04 AC 48 ms
59,648 KB
testcase_05 AC 43 ms
52,480 KB
testcase_06 AC 42 ms
52,736 KB
testcase_07 AC 47 ms
59,264 KB
testcase_08 AC 48 ms
59,264 KB
testcase_09 AC 45 ms
53,120 KB
testcase_10 AC 49 ms
59,776 KB
testcase_11 AC 52 ms
59,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Q = int(input())
for _ in range(Q):
    S = input()
    if len(S) <= 2 or S[0] != "0":
        print(S)
        continue
    cmd = S[1]
    num = list(S[2:])
    num.reverse()
    # print(num)
    now = 0
    if cmd == "b":
        k = 2
    elif cmd == "o":
        k = 8
    elif cmd == "x":
        k = 16
    else:
        print(S)
        continue
    for i, n in enumerate(num):
        if n == "a":
            n = "10"
        elif n == "b":
            n = "11"
        elif n == "c":
            n = "12"
        elif n == "d":
            n = "13"
        elif n == "e":
            n = "14"
        elif n == "f":
            n = "15"
        n = int(n)
        now += n * k**i
    print(now)
0