結果

問題 No.2385 Parse Integer with Radix
ユーザー pitPpitP
提出日時 2023-07-21 21:32:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 380 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 81,676 KB
実行使用メモリ 62,156 KB
最終ジャッジ日時 2023-10-21 21:23:47
合計ジャッジ時間 1,251 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,412 KB
testcase_01 AC 45 ms
59,604 KB
testcase_02 AC 44 ms
59,604 KB
testcase_03 AC 43 ms
59,604 KB
testcase_04 AC 41 ms
59,604 KB
testcase_05 AC 38 ms
53,412 KB
testcase_06 AC 40 ms
53,412 KB
testcase_07 AC 46 ms
62,156 KB
testcase_08 AC 40 ms
59,656 KB
testcase_09 AC 41 ms
59,656 KB
testcase_10 AC 45 ms
59,660 KB
testcase_11 AC 39 ms
59,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
	S = input()
	num = -1
	d = {}
	for i in range(10):
		d[str(i)] = i
	for i in range(6):
		d[chr(ord('a') + i)] = i + 10
# 2
	if S[0:2] == "0b":
		num = 2
		S = S[2:]
	elif S[0:2] == "0o":
		num = 8
		S = S[2:]
	elif S[0:2] == "0x":
		num = 16
		S = S[2:]
	else :
		num = 10
	ans = 0
	for i in range(len(S)):
		ans *= num
		ans += d[S[i]]
	print(ans)
0