Monday, September 16, 2019

Codeforce A. Life Without Zeros

  1. #include< iostream >
  2. using namespace std;
  3. int withOutZero(int n){
  4. int ans = 0;
  5. while(n != 0) {
  6. if(n%10 != 0)
  7. ans = n%10 + (ans *10) ;
  8. n /= 10;
  9. }
  10. return ans;
  11. }
  12. int main(){
  13. int n, m;
  14. cin >> n >> m;
  15. if(n == m) return cout << "YES" << endl, 0;
  16. int ans = n+m;
  17. ans = withOutZero(ans);
  18. ans = withOutZero(ans);
  19. n = withOutZero(n);
  20. n = withOutZero(n);
  21. m = withOutZero(m);
  22. m = withOutZero(m);
  23. if(ans == n+m) cout << "YES" << endl;
  24. else cout << "NO" << endl;
  25. return 0;
  26. }

No comments: