문제 링크
요약
- 쉬운문제
최종
결과
- 생각나는대로 풀면 풀린다.
#define LL(a) ((long long)(a))
class Solution {
public:
long long sumAndMultiply(int n) {
int x = 0;
int sum = 0;
while (n) {
int digit = n % 10;
if (digit) {
x = x * 10 + digit;
sum += digit;
}
n /= 10;
}
// Reverse
n = x;
x = 0;
while (n) {
x = x * 10 + (n % 10);
n /= 10;
}
return LL(x) * LL(sum);
}
};