天天看点

A. Guest From the Past 贪心

题目:

给 元钱,然后有塑料瓶的牛奶 元钱,玻璃瓶的牛奶 元钱,玻璃瓶可以卖 元钱。问

#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);
}