結果

問題 No.2385 Parse Integer with Radix
ユーザー まるくんまるくん
提出日時 2023-07-21 23:08:53
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,213 bytes
コンパイル時間 4,395 ms
コンパイル使用メモリ 262,116 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-22 00:39:35
合計ジャッジ時間 4,754 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

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