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