Submission #00017
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #include <cstdio> #include <cstdlib> #include <iostream> #include <algorithm> #include <cstring> #include <vector> #include <map> #include <cmath> #define rep(i,n) for(int i = 0;i < (n);i++) #define all(x) (x).begin(),(x).end() #define pb(x) push_back(x) #define mp(a,b) make_pair(a,b) using namespace std; typedef long long int ll; typedef vector< int > vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<pair< int , int > > vpi; typedef vector<pair<ll, ll> > vpl; int main(){ cin.tie(0); ios::sync_with_stdio( false ); string a, b; cin >> a >> b; string ans = "" ; rep(i,4){ if (( int )a.size()-i-1 >= 0 && ( int )b.size()-i-1 >= 0){ int c = ( int )(a[a.size()-i-1]- '0' )+( int )(b[b.size()-i-1]- '0' ); // cout << c << endl; ans += ( char )(c%10+ '0' ); } else { if (( int )a.size()-i-1 >= 0){ ans += a[a.size()-i-1]; } else if (( int )b.size()-1-i >= 0){ ans += b[b.size()-i-1]; } } } reverse(all(ans)); while (ans[0] == '0' ){ ans.erase(ans.begin()); } if (ans == "" ) cout << 0 << endl; else cout << ans << endl; return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0001 - A+B |
ユーザー名 | solooon |
投稿日時 | 2016-11-11 16:42:45 |
言語 | C++11 |
状態 | Accepted |
得点 | 100 |
ソースコード長 | 1156 Byte |
最大実行時間 | 26 ms |
最大メモリ使用量 | 664 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 100 / 100 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
00.in | AC | 16 ms | 480 KB |
1
|
00x.in | AC | 18 ms | 444 KB |
1
|
01.in | AC | 18 ms | 664 KB |
1
|
01x.in | AC | 26 ms | 628 KB |
1
|
02.in | AC | 15 ms | 472 KB |
1
|
03.in | AC | 20 ms | 444 KB |
1
|
04.in | AC | 19 ms | 412 KB |
1
|