結果

問題 No.2385 Parse Integer with Radix
ユーザー まるくんまるくん
提出日時 2023-07-21 23:08:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,213 bytes
コンパイル時間 4,372 ms
コンパイル使用メモリ 263,328 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 23:10:33
合計ジャッジ時間 5,054 ms
ジャッジサーバーID
(参考情報)
judge9 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
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 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 3 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using pii = pair<int, int>;
using pll = pair<long long, long long>;

using mint = modint998244353;
// using mint = modint1000000007;

// 定数
int INF = 1'000'000'007;
long long INFL = 2e18;
static const long double PI = acos(-1);

// 小数の出力桁数指定
__attribute__((constructor)) static void io_setup() noexcept {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout << std::fixed << std::setprecision(10);
  std::cerr << std::fixed << std::setprecision(10);
}

// rep Macro
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
  int Q;
  cin >> Q;
  string S;
  rep(qqq, Q) {
    cin >> S;
    ll ans;
    if (S.length() >= 2 and S[1] == 'b') {
      ans = stoll(S.substr(2), 0, 2);
    } else if (S.length() >= 2 and S[1] == 'o') {
      ans = stoll(S.substr(2), 0, 8);
    } else if (S.length() >= 2 and S[1] == 'x') {
      ans = stoll(S.substr(2), 0, 16);
    } else {
      ans = stoll(S);
    }
    cout << ans << endl;
  }
}
0