Codeforces Beta Round #67 (Div. 2) 75A - Life Without Zeros Solution
Problem Link: https://codeforces.com/problemset/problem/75/A
Solution in C++:
- /// La ilaha illellahu muhammadur rasulullah
- ///******Bismillahir-Rahmanir-Rahim******///
- /// Abul Hasnat Tonmoy
- /// Department of CSE,23rd batch
- /// Islamic University,Bangladesh
- ///**********ALLAH IS ALMIGHTY************///
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int a, b, c;
- cin >> a >> b;
- c = a + b;
- string a1, b1, c1, a2, b2, c2;
- a1 = to_string(a);
- b1 = to_string(b);
- c1 = to_string(c);
- for (int i = 0; i < a1.size(); i++) {
- if (a1[i] != '0') a2 += a1[i];
- }
- for (int i = 0; i < b1.size(); i++) {
- if (b1[i] != '0') b2 += b1[i];
- }
- for (int i = 0; i < c1.size(); i++) {
- if (c1[i] != '0') c2 += c1[i];
- }
- int a3, b3, c3;
- stringstream v1(a2), v2(b2), v3(c2);
- v1 >> a3, v2 >> b3, v3 >> c3;
- if (a3 + b3 == c3)
- cout << "YES" << endl;
- else
- cout << "NO" << endl;
- return 0;
- }
No comments