結果

問題 No.2086 A+B問題
コンテスト
ユーザー トミー
提出日時 2024-01-07 04:23:09
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 498 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,289 ms
コンパイル使用メモリ 213,908 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-07-03 08:57:50
合計ジャッジ時間 2,910 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12 WA * 8 RE * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:22:33: warning: ignoring return value of 'constexpr __gnu_cxx::__normal_iterator<_Iterator, _Container>::reference __gnu_cxx::__normal_iterator<_Iterator, _Container>::operator*() const [with _Iterator = int*; _Container = std::vector<int>; reference = int&]', declared with attribute 'nodiscard' [-Wunused-result]
   22 |                         *(itr-1)++;
      |                                 ^~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:67,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:62,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_iterator.h:1089:7: note: declared here
 1089 |       operator*() const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~

ソースコード

diff #
raw source code

#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