結果
問題 | No.2385 Parse Integer with Radix |
ユーザー | as277575 |
提出日時 | 2023-07-21 21:35:43 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,678 bytes |
コンパイル時間 | 1,067 ms |
コンパイル使用メモリ | 120,244 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-21 22:55:11 |
合計ジャッジ時間 | 1,622 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 |
ソースコード
#include <algorithm> #include <bit> #include <bitset> #include <cassert> #include <cstdio> #include <cstdlib> #include <cmath> #include <deque> #include <iostream> #include <map> #include <random> #include <unordered_set> #include <unordered_map> #include <vector> #include <set> #include <string> using namespace::std; template<typename T, typename U> ostream& operator<< (ostream& o, const pair<T, U>& p) { o << "<" << p.first << ", " << p.second << ">"; return o; } template <typename T> ostream& operator<< (ostream& o, const vector<T>& v) { for (const auto& x : v) o << x << " "; return o; } template <typename T> ostream& operator<< (ostream& o, const set<T>& v) { for (const auto& x : v) o << x << " "; return o; } template <typename T> ostream& operator<< (ostream& o, const deque<T>& v) { for (const auto& x : v) o << x << " "; return o; } template <typename K, typename V> ostream& operator<<(ostream& o, const unordered_map<K, V>& m) { o << "{"; for (const auto& [k, v] : m) o << " " << k << ": " << v << ","; o << "}"; return o; } template <typename T> istream& operator>> (istream& i, vector<T>& v) { for (auto& x : v) i >> x; return i; } istream& operator>> (istream& i, pair<int, int>& p) { i >> p.first >> p.second; return i; } int main() { ios::sync_with_stdio(false); int q; cin >> q; for (int i = 0; i < q; ++i) { string s; cin >> s; int base = 10; if (s.substr(0, 2) == "0b") base = 2; if (s.substr(0, 2) == "0o") base = 8; if (s.substr(0, 2) == "0x") base = 16; string r = base == 10 ? s : s.substr(2); cout << stoll(r, nullptr, base) << endl; } return 0; }