mhdew

CF 471_A

Mar 23rd, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4. #define in() freopen("in.txt", "r", stdin)
  5. #define out() freopen("out.txt", "w", stdout)
  6. double hh, mm;
  7. double h, d, c, n;
  8.  
  9. double with_disc()
  10. {
  11.     double time=((20-hh)*60)+mm;
  12.     double hlvl=h+(time*d);
  13.     double b=(hlvl*1.0)/n;
  14.     double bun=ceil(b);
  15.     double cost=bun*c;
  16.  
  17.     double disc=cost*0.2;
  18.     double ans=cost-disc;
  19.  
  20.     return ans;
  21. }
  22.  
  23. double without_disc()
  24. {
  25.     double hlvl=h;
  26.     double b=(hlvl*1.0)/n;
  27.     double bun=ceil(b);
  28.     double cost=bun*c;
  29.     double ans=cost*1.0;
  30.     return ans;
  31. }
  32.  
  33. int main()
  34. {
  35.     //in();
  36.     //out();
  37.     double wd,wtd;
  38.     scanf("%lf%lf", &hh,&mm);
  39.     scanf("%lf%lf%lf%lf", &h,&d,&c,&n);
  40.  
  41.     if(hh>=20){
  42.         double hlvl=h;
  43.         double b=(hlvl*1.0)/n;
  44.         double bun=ceil(b);
  45.         double cost=bun*c;
  46.         double disc=cost*0.2;
  47.         double ans=cost-disc;
  48.         printf("%0.4lf\n", ans);
  49.     }
  50.     else{
  51.         wd=with_disc();
  52.         wtd=without_disc();
  53.         if(wd<wtd)
  54.             printf("%0.4lf\n", wd);
  55.         else
  56.             printf("%0.4lf\n", wtd);
  57.     }
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment