CodeFoeces-955A

题目

原题链接:A. Feed the cat

题意

猫在hh:mm时醒来,饥饿度为h,每分钟增加d。每份猫粮卖c元能减少n饥饿度。20:00点后8折出售,问最少花多钱消除饥饿度。
由于想的太多,导致WA了几次。

代码

#include
using namespace std;
int main() {
    int hh,mm;
    double h,d,c,n;
    cin>>hh>>mm;
    cin>>h>>d>>c>>n;
    int t=hh*60+mm;
    if(hh<20){
        printf("%lf\n",min(ceil((d*(1200-t)+h)/n)*c*0.8,ceil(h/n)*c*1.0));
    }else{
        printf("%lf\n",ceil(h/n)*c*0.8);
    }
    return 0;
}

你可能感兴趣的:(CodeFoeces-955A)