// // Created by yudw on 2017/8/12. // #include <iostream> #include <vector> #include <algorithm> using namespace std; /* 2. 独立的小易  要注意小易的水果有初值 */ int main() {     int x, f, d, p; // 房租, 已有水果,d元钱, p元每个     while (cin>>x>>f>>d>>p)     {         int days = 0;         int day_cost = x + p;         if (f >0 && d > x)         {             if(d/x >= f)    // 有更多的钱             {                 days += f;                                  d -= x*f;                 f = 0;             }             else if(d/x < f)    // 钱不够             {                 days += d/x;                 d -= x*days;                 f -= days;             }         }         if(d < x )   //没钱了         {             cout<<days;         }         else if(d >= x ) // 还有钱, 水果已经吃完了         {             days += d / day_cost;             cout<<days<<endl;         }     }     return 0; }
点赞 评论

相关推荐

陌夏微秋:一线城市25w左右吧,17×15=255
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务