Skip to content

Commit

Permalink
Update 10757.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
sohyundoh committed Mar 25, 2022
1 parent d1e56b5 commit ffd032a
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions [브루트포스] 3월 24일/10757.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,55 @@ int main() {
reverse(a.begin(), a.end());
reverse(b.begin(), b.end());
int round;
int result[10000];
long long result[10000];
if (a_size > b_size) {
result[0] = ((int)a[0] + (int)b[0]) % 10;
round = ((int)a[0] + (int)b[0]) / 10;
for (int i = 1; i < a_size; i++) {
result[0] = ((int)(a[0] - '0' + b[0] - '0')) % 10;
round = ((int)(a[0] - '0' + b[0] - '0')) / 10;
for (int i = 1; i < a_size + 1; i++) {
if (i <= b_size) {
result[i] = ((int)a[i] + (int)b[i] + round) % 10;
round = ((int)a[i] + (int)b[i] + round) / 10;
result[i] = ((int)(a[i] - '0' + b[i] - '0') + round) % 10;
round = ((int)(a[i] - '0' + b[i] - '0') + round) / 10;
}
else {
result[i] = ((int)a[i] + round) % 10;
round = ((int)a[i] + round) / 10;
result[i] = ((int)(a[i] - '0') + round) % 10;
round = ((int)(a[i] - '0') + round) / 10;
}
}
if (result[a_size] > 0) {
reverse(result, result + a_size);
if (result[a_size + 1] > 0) {
reverse(result, result + a_size + 1);
for (int i = 0; i < (a_size + 1); i++) {
cout << result[i];
}
}
else {
reverse(result, result + a_size - 1);
reverse(result, result + a_size);
for (int i = 0; i < (a_size); i++) {
cout << result[i];
}
}

}
else {
result[0] = ((int)a[0] + (int)b[0]) % 10;
round = ((int)a[0] + (int)b[0]) / 10;
for (int i = 1; i < b_size; i++) {
result[0] = ((int)(a[0] - '0' + b[0] - '0')) % 10;
round = ((int)(a[0] - '0' + b[0] - '0')) / 10;
for (int i = 1; i < b_size + 1; i++) {
if (i <= a_size) {
result[i] = ((int)a[i] + (int)b[i] + round) % 10;
round = ((int)a[i] + (int)b[i] + round) / 10;
result[i] = ((int)((a[i] - '0') + (b[i] - '0')) + round) % 10;
round = ((int)((a[i] - '0') + (b[i] - '0')) + round) / 10;
}
else {
result[i] = ((int)b[i] + round) % 10;
round = ((int)b[i] + round) / 10;
result[i + 1] = ((int)(b[i] - '0') + round) % 10;
round = ((int)(b[i] - '0') + round) / 10;
};
}
if (result[b_size] > 0) {
reverse(result, result + b_size);
if (result[b_size + 1] > 0) {
reverse(result, result + b_size + 1);
for (int i = 0; i < (b_size + 1); i++) {
cout << result[i];
}
}
else {
reverse(result, result + b_size - 1);
reverse(result, result + b_size);
for (int i = 0; i < (b_size); i++) {
cout << result[i];
}
Expand Down

0 comments on commit ffd032a

Please sign in to comment.