CodeForces 625A Guest From the Past

贪心水题

#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <queue>
#include <stack>
#include <map>
#include <vector>
using namespace std;

long long ans;
long long n,a,b,c;

int main()
{

    scanf("%lld%lld%lld%lld",&n,&a,&b,&c);
    ans=0;

    if(a<=b-c) ans=n/a;
    else
    {
        if(n>=b)
        {
            ans=(n-b)/(b-c);
            n=n-ans*(b-c);
            if(n>=b) ans++,n=n-b+c;
        }

        ans=ans+n/a;
    }
    printf("%lld
",ans);
    return 0;
}
原文地址:https://www.cnblogs.com/zufezzt/p/5188490.html