【Luogu3926】SAC E#1 - 一道不可做题 Jelly

problem

solution

codes

//巧妙的利用了x-=min(x,t); x若剩余为0则下面升温也为0
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
int main(){
    LL a, c, p, q, r, x, t;
    cin>>a>>c>>p>>q>>r>>x;
    if(a < c){ //温度小于c,需要加热到解冻温度
        t = min(x, p*(c-a));  //1.(t=x)加热不到c,那么x=0,r不需要加,a+=t/p即可
        x -= t;  //2.(t=p*(c-c)) 加热到了c, 此时a==c, x=x-t,也就是剩下的时间
        a += t/p;  //更新a的值为加热的时间除以解冻以前每秒升高的温度
    }
    if(a == c){ //温度达到了解冻温度
        x -= min(x, q); //解冻需要的时间(若是不够解冻,则x==0,a值不变
    }
    a += x/r;   //a要加上剩余的时间除以解冻以后每秒升高的温度;
    cout<<a<<"\n"; 
    return 0;
}
posted @ 2018-06-04 21:45  gwj1139177410  阅读(114)  评论(0编辑  收藏  举报
选择