Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int a,b,c;
- cin>>a>>b>>c;
- int ans = 1e9;
- for(int i=1;i<=4;i++) for(int j=1;j<=4;j++)
- {
- int s = a;
- if(i==4) if(s%b==0) s/= b; else continue;
- else if(i==3) s*=b;
- else if(i==2) s-=b;
- else if(i==1) s+=b;
- if(j==4) if(s%c==0) s/= c; else continue;
- else if(j==3) s*=c;
- else if(j==2) s-=c;
- else if(j==1) s+=c;
- if(s>=0) ans = min(ans,s);
- }
- cout << ans << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment