题目:
A. Guest From the Past 贪心_5e 元钱,然后有塑料瓶的牛奶 A. Guest From the Past 贪心_#include_02 元钱,玻璃瓶的牛奶 A. Guest From the Past 贪心_#include_03 元钱,玻璃瓶可以卖 A. Guest From the Past 贪心_ios_04元钱。问 A. Guest From the Past 贪心_5e

思路:
如果一种样式的牛奶贡献大,那我们就一直喝这个到不能在喝为止,剩下的钱看看还能否喝其他种的牛奶即可,呢么存在两种情况,全喝 A. Guest From the Past 贪心_#include_02 牛奶,剩余的钱只能喝 A. Guest From the Past 贪心_#include_03,反则全喝A. Guest From the Past 贪心_#include_03,剩下的钱全喝 A. Guest From the Past 贪心_#include_02

参考代码:

#include<iostream>
#include<vector>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<set>
#include<cstdlib>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<set>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
const int N=5e2+5;
int read(int &v)
{
int k = 1;
v = 0;
int c = getchar();
while (c < '0' || c > '9')
{
if (c == '-')
k = 0;
c = getchar();
}
while (c >= '0' && c <= '9')
v = (v << 3) + (v << 1) + (c - 48), c = getchar();
if (k == 0)
v = -v;
return c;
}
ll ksm(ll a,ll b)
{
ll res=1;
while(b)
{
if(b&1)
res*=a;
b>>=1,a=a*a;
}
return res;
}
ll solve(ll n,ll b,ll c)
{
ll ans=0;
while(n>=b)
{
ans+=n/b;
n=n-(n/b)*b+(n/b)*c;
}
return ans;
}
int main()
{
ll n,a,b,c;
scanf("%lld %lld %lld %lld",&n,&a,&b,&c);
if(n<a&&n<b)
{
puts("0");
return 0;
}
ll ans=(n/a);
ll res=0;
if(n>=b)
{
res=(n-c)/(b-c);
res+=(n-(b-c)*res)/a;
}
if(ans<res)
printf("%lld\n",res);
else
printf("%lld\n",ans);
}