結果

問題 No.2086 A+B問題
ユーザー トミートミー
提出日時 2024-01-07 04:23:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 498 bytes
コンパイル時間 6,318 ms
コンパイル使用メモリ 203,184 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-07 04:23:17
合計ジャッジ時間 3,621 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 1 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
6,676 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
	string a,b,temp;
	cin>>a>>b;
	int l=a.size()-b.size();
	vector<int> d(max(a.size(),b.size())+1);
	if(l<0){
		temp=a;
		a=b;
		b=temp;
	}
	for(int i=0;i<l;i++){
		d[i+1]=a[i]-'0';
	}
	for(int i=l;i<=a.size();i++){
		d[i+1]=a[i]+b[i-l]-2*'0';
	}
	for(auto itr=d.end()-1;itr>=d.begin();itr--){
		if(*itr>=10){
			*(itr-1)++;
			*itr-=10;
		}
	}
	
	if(d[0]!=0){
		cout<<1;
	}
	for(auto itr=d.begin()+1;itr!=d.end();itr++){
		cout<<*itr;
	}

}
0