SHARE
TWEET

C++ solution for problem A

ahmed_aly Apr 13th, 2011 1,426 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cstring>
  2. #include <map>
  3. #include <deque>
  4. #include <queue>
  5. #include <stack>
  6. #include <sstream>
  7. #include <iostream>
  8. #include <iomanip>
  9. #include <cstdio>
  10. #include <cmath>
  11. #include <cstdlib>
  12. #include <ctime>
  13. #include <algorithm>
  14. #include <vector>
  15. #include <set>
  16. #include <complex>
  17. #include <list>
  18. #include <climits>
  19. #include <cctype>
  20.  
  21. using namespace std;
  22.  
  23. int removeZeros(int num) {
  24.         int ret = 0;
  25.         int ten = 1;
  26.         while (num) {
  27.                 int dig = num % 10;
  28.                 num /= 10;
  29.                 if (dig) {
  30.                         ret += dig * ten;
  31.                         ten *= 10;
  32.                 }
  33.         }
  34.         return ret;
  35. }
  36.  
  37. int main() {
  38.         int a, b, c;
  39.         cin >> a >> b;
  40.         c = a + b;
  41.         a = removeZeros(a);
  42.         b = removeZeros(b);
  43.         c = removeZeros(c);
  44.         if (a + b == c)
  45.                 cout << "YES" << endl;
  46.         else
  47.                 cout << "NO" << endl;
  48.         return 0;
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top