結果
問題 |
No.222 引き算と足し算
|
ユーザー |
![]() |
提出日時 | 2016-02-16 21:45:35 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 756 bytes |
コンパイル時間 | 625 ms |
コンパイル使用メモリ | 58,676 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-15 22:10:09 |
合計ジャッジ時間 | 1,623 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include <iostream> #include <vector> using namespace std; #define REP(i,s,e) for (int i = s; i < e; i++) #define rep(i,n) REP(i,0,n) int main() { string s; cin >> s; int x, y, tmp; auto p = s.begin(); x = 1; if (*p == '+') p++; else if (*p == '-') { x = -1; p++; } for (tmp = 0;'0' <= *p && *p <= '9'; p++) tmp = tmp * 10 + *p - '0'; x *= tmp; y = 1; if (*p == '+') { y = -1; p++; } else if (*p == '-') p++; if (*p == '+') p++; else if (*p == '-') { y = -y; p++; } for (tmp = 0;'0' <= *p && *p <= '9'; p++) tmp = tmp * 10 + *p - '0'; y *= tmp; cout << x + y << endl; return 0; }