結果

問題 No.2385 Parse Integer with Radix
ユーザー ococonomy1ococonomy1
提出日時 2023-07-21 21:23:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,742 bytes
コンパイル時間 1,054 ms
コンパイル使用メモリ 107,968 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 21:10:12
合計ジャッジ時間 1,683 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <climits>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using lg = long long;
using pii = pair<int, int>;
using pll = pair<lg, lg>;
#define TEST cerr << "TEST" << endl
#define AMARI 998244353
// #define AMARI 1000000007
#define TEMOTO ((sizeof(long double) == 16) ? false : true)
#define TIME_LIMIT 1980 * (TEMOTO ? 1 : 1000)
#define el '\n'
#define El '\n'

#define MULTI_TEST_CASE true 
void solve(void) {
    string s;
    cin >> s;
    if(s.size() == 1){
        cout << 0 << el;
        return;
    }
    if(s[1] == 'b'){
        lg ans = 0;
        for(int i = 2; i < s.size(); i++){
            ans *= 2;
            ans += s[i] - '0';
        }
        cout << ans << el;
        return;
    }
    if(s[1] == 'o'){
        lg ans = 0;
        for(int i = 2; i < s.size(); i++){
            ans *= 8;
            ans += s[i] - '0';
        }
        cout << ans << el;
        return;
    }
    if(s[1] == 'x'){
        lg ans = 0;
        for(int i = 2; i < s.size(); i++){
            ans *= 16;
            if(s[i] >= 'a' && s[i] <= 'f')ans += s[i] - 'a' + 10;
            else ans += s[i] - '0';
        }
        cout << ans << el;
        return;
    }
    cout << s << el;
    return;
}

void calc(void) {
    return;
}

int main(void) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    calc();
    int t = 1;
    if (MULTI_TEST_CASE) cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
0