結果

問題 No.2086 A+B問題
ユーザー umimelumimel
提出日時 2022-09-30 21:27:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,188 bytes
コンパイル時間 1,711 ms
コンパイル使用メモリ 169,632 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-22 22:18:46
合計ジャッジ時間 2,304 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll INF = 1LL << 60;
const ll MAX_N = 2e5;
int main(){
string a, b;
cin >> a >> b;
ll na = (ll)a.size();
ll nb = (ll)b.size();
for(ll i=0; i<na/2; i++) swap(a[i], a[na-1-i]);
for(ll i=0; i<nb/2; i++) swap(b[i], b[nb-1-i]);
string c="";
ll carry = 0;
rep(i, min(na, nb)){
ll x = (a[i]-'0') + (b[i]-'0') + carry;
c += (x%10 + '0');
carry = x/10;
}
for(ll i=min(na, nb); i<max(na, nb); i++){
if(na > nb){
ll x = (a[i]-'0') + carry;
c += (x%10 + '0');
carry = x/10;
}else{
ll x = (b[i]-'0') + carry;
c += (x%10 + '0');
carry = x/10;
}
}
if(carry > 0) c += (carry + '0');
ll nc = (ll)c.size();
for(ll i=0; i<nc/2; i++) swap(c[i], c[nc-1-i]);
cout << c << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0