結果
問題 | No.8062 A + B |
ユーザー |
![]() |
提出日時 | 2020-04-01 22:24:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,781 bytes |
コンパイル時間 | 857 ms |
コンパイル使用メモリ | 97,808 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-27 11:35:19 |
合計ジャッジ時間 | 1,371 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <string> #include <queue> #include <stack> #include <set> #include <map> #include <iomanip> #include <utility> #include <tuple> #include <functional> #include <bitset> #include <cassert> #include <complex> #include <stdio.h> #include <time.h> #define int long long #define endl '\n' #define INF 1000000000000000000 #define EPS 1e-10 #define PI 3.141592653589793238 #define all(a) a.begin(),a.end() #define rep(i, n) for (int i = 0; i < (n); i++) #define pb push_back #define double long double using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<P, ll> PP; typedef complex<double> com; template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; } template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; } ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); } ll lcm(ll n, ll m) { return n / gcd(n, m)*m; } int stolll(string s) { if (s == "") return 0; else return stoll(s); } signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); //modcalc(); string a, b; cin >> a >> b; string s = a + b; if (s.size() >= 19) { bool flag = true; bool flag2 = false; for (char c : s) { if (flag2) { if (c == '-' || c == '+') { flag = false; } } flag2 = true; } if (flag) { cout << s << endl; return 0; } } int ans = 0; int mode = 1; string now = ""; for (char c : s) { if (c == '-') { ans += stolll(now)*mode; now = ""; mode = -1; } else if (c == '+') { ans += stolll(now)*mode; now = ""; mode = -1; } else { now += c; } } ans += stolll(now)*mode; cout << ans << endl; }