Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int broj1, broj2;
- cin >> broj1 >> broj2;
- int a1 = broj1 % 10;
- broj1 /= 10;
- int a2 = broj1 % 10;
- broj1 /= 10;
- int a3 = broj1 % 10;
- broj1 /= 10;
- int a4 = broj1 % 10;
- broj1 /= 10;
- int b1 = broj2 % 10;
- broj2 /= 10;
- int b2 = broj2 % 10;
- broj2 /= 10;
- int b3 = broj2 % 10;
- broj2 /= 10;
- int b4 = broj2 % 10;
- broj2 /= 10;
- int res = 0;
- int minus1 = min(10 - a1 + b1, 10 - b1 + a1);
- int minus2 = min(10 - a2 + b2, 10 - b2 + a2);
- int minus3 = min(10 - a3 + b3, 10 - b3 + a3);
- int minus4 = min(10 - a4 + b4, 10 - b4 + a4);
- res += min(abs(b1 - a1), minus1);
- res += min(abs(b2 - a2), minus2);
- res += min(abs(b3 - a3), minus3);
- res += min(abs(b4 - a4), minus4);
- cout << res << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement