結果

問題 No.2086 A+B問題
ユーザー madokamadoka
提出日時 2022-09-30 22:32:39
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 3,646 bytes
コンパイル時間 1,232 ms
コンパイル使用メモリ 147,848 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-24 16:07:13
合計ジャッジ時間 2,279 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <bits/stdc++.h>
#include <time.h>
#include <stack>
#include <array>



#define popcount __builtin_popcount
using namespace std;

#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define rrep(i,x) for(long long i=x-1;i>=0;i--)
#define rrepn(i,x) for(long long i=x;i>1;i--)
#define REP(i,n,x) for(long long i=n;i<x;i++)
#define REPN(i,n,x) for(long long i=n+1;i<x;i++)

#define re return
#define fi first
#define se second
#define pr printf
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

#define all(x) (x).begin(),(x).end()

typedef long long int ll;

const double PI=3.14159265358979323846;
//#define INF 1e18+5//19桁
#define INF 9223372036854775807
//-9,223,372,036,854,775,808~9,223,372,036,854,775,807
//-9223372036854775808~9223372036854775807

#define inf  INT_MAX//19桁
//#define mp make_pair
//using lll=__int128_t;

const ll mask=(1<<20)-1;
typedef pair<long long, long long> P;


//int dp[MAX][MAX];
const int MAX = 500;
const int MOD = 1000000007;
//#define MAX 105
ll wk,wk1,wk2,wk3,wk4;
double dA,dB,dC,dD,dE,dF,dG,dH,dI,dJ,dK,dL,dM,dN,dO,dP,dQ,dR,dS,dT,dU,dV,dW,dX,dY,dZ;
double dwk,dwk1,dwk2,dwk3,dwk4,dsum;
ll A,B,C,D,E,F,G,I,J,K,L,M,N,O,R,S,T,U,V,X,Y,Z;//P,Q,H,Wは無し
//ll a,b,c,d,e,f,g,i,j,k,l,m,n,o,r,s,t,u,v,x,y,z;//p,q,h,wは無し
ll cnt,flg;
ll ans,sum=0;
//int n;
//int t[200020];
//int a[200020], b[200020];

//vector<ll> A[MAX];
//int ans[200020];

//#define mod 1000000007//atcoder/allを使う時にはコメントアウト
//#define mod 998244353//atcoder/allを使う時にはコメントアウト

//g++ new_formatcopy.cpp -std=c++14 -I /mnt/c/code/
//もしくはexport CPATH=$CPATH:/mnt/c/code/

//**************ここまでフォーマット***************



int main(){	
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll max=0;
    ll min=INF;

    string s,t;
    cin>>s>>t;
    if(s.size()<t.size()){
        swap(s,t);
    }
    reverse(all(s));
    reverse(all(t));
    vector<ll>kotae;
    for(ll i=0;i<s.size();i++){
        if(i>=t.size()){
            if(flg==1){
                kotae.push_back((s[i]-'0')+1);
                flg=0;
            }
            else{
                kotae.push_back((s[i]-'0'));
                flg=0;
            }
        }
        else{
            if(flg==1){
                if((s[i]-'0')+(t[i]-'0')+1>=10){
                    kotae.push_back(((s[i]-'0')+(t[i]-'0')+1-10));
                    flg=1;
                }
                else{
                    kotae.push_back(((s[i]-'0')+(t[i]-'0')+1));
                    flg=0;
                }
            }
            else{
                if((s[i]-'0')+(t[i]-'0')>=10){
                    kotae.push_back(((s[i]-'0')+(t[i]-'0')-10));
                    flg=1;
                }
                else{
                    kotae.push_back(((s[i]-'0')+(t[i]-'0')));
                    flg=0;
                }
            }
        }
    }
    reverse(all(kotae));
    rep(i,kotae.size()){
        cout<<kotae[i];
    }
    cout<<"\n";
    

}
0