码迷,mamicode.com
首页 > 其他好文 > 详细

CodeForces 625A Guest From the Past

时间:2016-02-14 01:37:11      阅读:123      评论:0      收藏:0      [点我收藏+]

标签:

贪心水题

#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\n",ans);
    return 0;
}

 

CodeForces 625A Guest From the Past

标签:

原文地址:http://www.cnblogs.com/zufezzt/p/5188490.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!