按照题意模拟即可。如果 ,输出 。如果 且 ,输出 ,注意分数不能为负数,如果 要输出 ,也就是输出 与 的最大值。如果 ,输出 。
代码
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ft first
#define sd second
#define fs(i,x,y) for(int i=(x);i<=(y);i++)
#define fj(i,x,y) for(int i=(x);i>=(y);i--)
signed main(){
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,a,b,c;
cin>>n>>a>>b>>c;
if(a==b)cout<<n+c;
else if(a!=0&&a!=b)cout<<max(0ll,n-c/4);
else cout<<n;
return 0;
}