結果

問題 No.2385 Parse Integer with Radix
ユーザー ikomaikoma
提出日時 2023-07-21 21:25:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 379 bytes
コンパイル時間 520 ms
コンパイル使用メモリ 81,624 KB
実行使用メモリ 59,720 KB
最終ジャッジ日時 2023-10-21 21:13:27
合計ジャッジ時間 1,474 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import sys
input = sys.stdin.readline

Q=int(input())

for _ in range(Q):
    S=input().strip()
    if len(S)<2:
        print(S)
        continue
    ans=0
    Q,s=S[:2],S[2:]
    if Q=="0b":
        q=2
    elif Q=="0o":
        q=8
    elif Q=="0x":
        q=16
    else:
        print(S)
        continue
    for s_ in s:
        ans*=q
        ans+=int(s_,q)
    print(ans)
0