結果
問題 | No.8062 A + B |
ユーザー | mencotton |
提出日時 | 2020-04-01 22:41:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 751 bytes |
コンパイル時間 | 6,257 ms |
コンパイル使用メモリ | 281,148 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-27 11:59:16 |
合計ジャッジ時間 | 5,275 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 |
ソースコード
#include <iostream> #include <boost/multiprecision/cpp_int.hpp> using namespace std; using Bint = boost::multiprecision::cpp_int; string s; Bint num(int &index) { Bint ret = 0; while (index < s.size() && isdigit(s[index])) { ret *= 10; ret += s[index] - '0'; index++; } return ret; } Bint calc(int &index) { Bint ret = num(index); while (index < s.size()) { if (s[index] == '+') { index++; ret += num(index); } else if (s[index] == '-') { index++; ret -= num(index); } } return ret; } int main() { string a, b; cin >> a >> b; s = "0" + a + b; int usi = 0; cout << calc(usi) << endl; return 0; }