結果
| 問題 |
No.222 引き算と足し算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-09-21 00:58:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 356 bytes |
| コンパイル時間 | 522 ms |
| コンパイル使用メモリ | 64,652 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-08 09:23:45 |
| 合計ジャッジ時間 | 1,792 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
4 | main()
| ^~~~
ソースコード
#include<iostream>
using namespace std;
string s;
main()
{
cin>>s;
int i=0,A=0,B=0;
bool a,b,c;
a=s[i]=='+'?i++,1:s[i]=='-'?i++,0:1;
while(s[i]>='0'&&s[i]<='9')
{
A=A*10+s[i]-48;
i++;
}
b=s[i++]=='+';
c=s[i]=='+'?i++,1:s[i]=='-'?i++,0:1;
while(s[i]>='0'&&s[i]<='9'){
B=B*10+s[i]-48;
i++;
}
cout<<A*(a?1:-1)+(b?-1:1)*B*(c?1:-1)<<endl;
}