Submission #15133

#TimeUsernameProblemLanguageResultExecution timeMemory
15133ddaafftt꼬마 정민 (kriii3_RR)C++14
20 / 20
0 ms1720 KiB
#include <iostream> #include <string> using namespace std; int main(void) { string s1, s2, s3; string s, l; string result; string result2; int sub; char c = '0'; int carry = 0; cin >> s1 >> s2 >> s3; s = (s1.size() > s2.size() ? s2 : s1); l = (s1.size() > s2.size() ? s1 : s2); sub = l.size() - s.size(); for (int i = s.size() - 1; i >= 0; --i) { c = (l[i + sub] - '0') + (s[i] - '0') + carry; if (10 <= c) carry = 1; else carry = 0; result.insert(0, 1, (c % 10) + '0'); } for (int i = sub - 1; i >= 0; --i) { c = (l[i] - '0') + carry; if (10 <= c) carry = 1; else carry = 0; result.insert(0, 1, (c % 10) + '0'); } if (1 == carry) result.insert(0, 1, '1'); carry = 0; s = (result.size() > s3.size() ? s3 : result); l = (result.size() > s3.size() ? result : s3); sub = l.size() - s.size(); for (int i = s.size() - 1; i >= 0; --i) { c = (l[i + sub] - '0') + (s[i] - '0') + carry; if (10 <= c) carry = 1; else carry = 0; result2.insert(0, 1, (c % 10) + '0'); } for (int i = sub - 1; i >= 0; --i) { c = (l[i] - '0') + carry; if (10 <= c) carry = 1; else carry = 0; result2.insert(0, 1, (c % 10) + '0'); } if (1 == carry) result2.insert(0, 1, '1'); cout << result2; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...