結果

問題 No.3062 A + B
ユーザー furafura
提出日時 2020-04-01 23:37:26
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 456 bytes
コンパイル時間 2,178 ms
コンパイル使用メモリ 199,636 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 20:18:07
合計ジャッジ時間 2,864 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,384 KB
testcase_07 WA -
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	string a,b; cin>>a>>b;

	string s=a+b;
	int n=s.length();
	lint ans=0,num=0;
	int sgn=1;
	rep(i,n+1){
		if(i==n || s[i]=='+' || s[i]=='-'){
			ans+=sgn*num;
			num=0;
			if(i<n){
				if(i==0 || isdigit(s[i-1])) sgn=1;
				if(s[i]=='-') sgn*=-1;
			}
		}
		else{
			num=10*num+(s[i]-'0');
		}
	}
	printf("%lld\n",ans);

	return 0;
}
0