結果
問題 | No.2086 A+B問題 |
ユーザー |
![]() |
提出日時 | 2023-07-05 00:37:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 858 bytes |
コンパイル時間 | 2,054 ms |
コンパイル使用メモリ | 195,296 KB |
最終ジャッジ日時 | 2025-02-15 06:03:11 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 WA * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #define _GLIBCXX_DEBUG #else #define Debug(...) void(0) #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); ++i) int main() { string a, b; cin >> a >> b; reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); string ans = ""; rep(i, max(a.size(), b.size())) { int x = (i >= a.size() ? 0 : a[i] - '0'); int y = (i >= b.size() ? 0 : b[i] - '0'); if (x + y >= 10) { ans += to_string((x + y) % 10); if (i >= a.size() - 1 && i >= b.size() - 1) { ans += "1"; } else if (i >= a.size() - 1) { a[i + 1]++; } else { b[i + 1]++; } } else { ans += to_string(x + y); } } reverse(ans.begin(), ans.end()); cout << ans << endl; return 0; }