Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define llong long long
- using namespace std;
- int a, b;
- int binplus(int a, int b) {
- if(!b) return a;
- if(b % 2 == 0) {
- int res = binplus(a, b / 2);
- return res + b / 2;
- }
- else {
- return binplus(a, b - 1) + 1;
- }
- }
- int main() {
- cin >> a >> b;
- if(a < 0 && b < 0) a = -a, b = -b, cout << '-';
- else if(b < 0) swap(a, b);
- cout << binplus(a, b);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement