結果
| 問題 |
No.2385 Parse Integer with Radix
|
| コンテスト | |
| ユーザー |
銀貨🪙
|
| 提出日時 | 2023-07-21 21:36:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 843 bytes |
| コンパイル時間 | 1,585 ms |
| コンパイル使用メモリ | 166,788 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-21 22:57:40 |
| 合計ジャッジ時間 | 1,990 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 11 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int q;
cin>>q;
for(int i=0;i<q;i++) {
string s;
cin>>s;
ll ans=0;
if (s.size()==1) {cout<<s<<"\n";continue;}
else if(s[1]=='b') {
ll now = 1;
for(int j=0;j<s.size()-2;j++) {
ans+=(s[s.size()-1-j]-'0')*now;
now*=2;
}
cout<<ans;
}
else if(s[1]=='o') {
ll now = 1;
for(int j=0;j<s.size()-2;j++) {
ans+=(s[s.size()-1-j]-'0')*now;
now*=8;
}
cout<<ans;
}
else if(s[1]=='x') {
ll now = 1;
for(int j=0;j<s.size()-2;j++) {
if ('a'<=s[s.size()-1-j]) ans+=(s[s.size()-1-j]-'a'+10)*now;
else ans+=(s[s.size()-1-j]-'0')*now;
now*=16;
}
cout<<ans;
}
else {
cout<<s;
}
cout<<"\n";
}
}
銀貨🪙