結果
問題 |
No.222 引き算と足し算
|
ユーザー |
![]() |
提出日時 | 2015-06-05 22:38:25 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 884 bytes |
コンパイル時間 | 1,435 ms |
コンパイル使用メモリ | 158,344 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-15 21:23:37 |
合計ジャッジ時間 | 2,135 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 2 WA * 29 |
ソースコード
#include <bits/stdc++.h> #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,b) FOR(i,0,b) #define X real() #define Y imag() #define S second; #define F first; #define PB(a) push_back(a) #define BE(c) c.begin(),c.end() using namespace std; typedef long long LL; typedef pair<int,int> pr; typedef pair<pr,int> ppr; typedef priority_queue<pr,vector<pr>,greater<pr> > PQ; typedef vector<pr> Vpr; typedef vector<LL> VI; typedef complex<LL> cld; typedef vector<cld> Vcld; const int SIZE=1000010; const LL INF=1<<30; int main(){ string s; int now=0,type=1,pm=1,ans=0; cin >> s; while(now!=s.size()){ if(type==1){ if(s[now]=='-') pm*=-1; else pm*=1; if(s[now]!='-' && s[now]!='+') type++; } if(type==2) ans+=pm*(s[now]-'0'); else if(type==0){ if(s[now]=='-') pm=1; else pm=-1; } now++; type++; type%=3; } cout << ans << endl; return 0; }