結果
| 問題 |
No.2385 Parse Integer with Radix
|
| コンテスト | |
| ユーザー |
nikoro256
|
| 提出日時 | 2023-07-21 21:31:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 55 ms / 2,000 ms |
| コード長 | 535 bytes |
| コンパイル時間 | 193 ms |
| コンパイル使用メモリ | 82,384 KB |
| 実行使用メモリ | 59,776 KB |
| 最終ジャッジ日時 | 2024-09-21 22:49:15 |
| 合計ジャッジ時間 | 1,333 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 11 |
ソースコード
Q=int(input())
for i in range(Q):
S=input()
d=1
if len(S)<2:
print(S)
continue
if S[:2]=='0b':
d=2
elif S[:2]=='0o':
d=8
elif S[:2]=='0x':
d=16
else:
print(S)
continue
exp=1
ans=0
s={'a','b','c','d','e','f'}
dic={'a':10,'b':11,'c':12,'d':13,'e':14,'f':15}
for j in range(len(S)-1,1,-1):
k=0
if S[j] in s:
k=dic[S[j]]
else:
k=int(S[j])
ans+=exp*k
exp*=d
print(ans)
nikoro256