結果
問題 |
No.8062 A + B
|
ユーザー |
|
提出日時 | 2020-04-01 22:23:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 657 bytes |
コンパイル時間 | 1,038 ms |
コンパイル使用メモリ | 86,508 KB |
最終ジャッジ日時 | 2025-01-09 12:12:17 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 3 WA * 5 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <queue> #include <map> #include <set> #include <bitset> using namespace std; typedef long long ll; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); string s,t; cin >> s >> t; s+="+"; s=s+t; ll ans=0; ll num=0; int sign=1; s="+"+s; int n=s.size(); for(int i=0;i<s.size();i++){ sign=1; if(s[i]=='+'||s[i]=='-'){ while(i<n&&(s[i]=='+'||s[i]=='-')){ if(s[i]=='-')sign^=1; i++; } num=0; while(i<n&&'0'<=s[i]&&s[i]<='9'){ num*=10; num+=(s[i]-'0'); i++; } i--; if(sign==0)sign=-1; ans+=num*sign; } } cout << ans << endl; }