fork download
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4.  
  5. using namespace std;
  6. using namespace __gnu_pbds;
  7. using ll = long long;
  8. using ld = long double;
  9.  
  10. #define all(x) x.begin(),x.end()
  11. #define v(x) vector<x>
  12. #define nl '\n'
  13. #define fxd(x) fixed << setprecision(x)
  14. template<class t> using ordered_set = tree<t, null_type, less<t>, rb_tree_tag, tree_order_statistics_node_update>;
  15. template<class t> using ordered_multiset = tree<t, null_type, less_equal<t>, rb_tree_tag, tree_order_statistics_node_update>;
  16.  
  17.  
  18. int main()
  19. {
  20. ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  21. int a , b ,c; cin >> a >> b;
  22. c = a+b;
  23. string x = to_string(a);
  24. string y = to_string(b);
  25. string z = to_string(c);
  26. for (int i = 0; i < x.length(); i++)
  27. {
  28. if(x[i] == '0')
  29. {
  30. x.erase(x.begin()+i);
  31. i--;
  32. }
  33. }
  34. for (int i = 0; i < y.length(); i++)
  35. {
  36. if(y[i] == '0')
  37. {
  38. y.erase(y.begin()+i);
  39. i--;
  40. }
  41. }
  42. for (int i = 0; i < z.length(); i++)
  43. {
  44. if(z[i] == '0')
  45. {
  46. z.erase(z.begin()+i);
  47. i--;
  48. }
  49. }
  50.  
  51. a = stoi(x);
  52. b = stoi(y);
  53. c = stoi(z);
  54. if(a+b == c)
  55. {
  56. cout << "YES";
  57. }
  58. else
  59. {
  60. cout << "NO";
  61. }
  62. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
YES