Codeforces Beta Round #67 (Div. 2) 75A - Life Without Zeros Solution



  Problem Link:  https://codeforces.com/problemset/problem/75/A

Solution in C++:

  1. /// La ilaha illellahu muhammadur rasulullah
  2. ///******Bismillahir-Rahmanir-Rahim******///
  3. /// Abul Hasnat Tonmoy
  4. /// Department of CSE,23rd batch
  5. /// Islamic University,Bangladesh
  6. ///**********ALLAH IS ALMIGHTY************///
  7. #include <bits/stdc++.h>
  8. using namespace std;
  9. int main() {
  10. int a, b, c;
  11. cin >> a >> b;
  12. c = a + b;
  13. string a1, b1, c1, a2, b2, c2;
  14. a1 = to_string(a);
  15. b1 = to_string(b);
  16. c1 = to_string(c);
  17. for (int i = 0; i < a1.size(); i++) {
  18. if (a1[i] != '0') a2 += a1[i];
  19. }
  20. for (int i = 0; i < b1.size(); i++) {
  21. if (b1[i] != '0') b2 += b1[i];
  22. }
  23. for (int i = 0; i < c1.size(); i++) {
  24. if (c1[i] != '0') c2 += c1[i];
  25. }
  26. int a3, b3, c3;
  27. stringstream v1(a2), v2(b2), v3(c2);
  28. v1 >> a3, v2 >> b3, v3 >> c3;
  29. if (a3 + b3 == c3)
  30. cout << "YES" << endl;
  31. else
  32. cout << "NO" << endl;
  33. return 0;
  34. }

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.