3128 - 计算水费
为提倡节约用水,某城市实行了新的用水价格,规定5口之家每月的用水量基准数为8吨。若用水量在基准数内(包含基准数)则按每吨2.5元计算;若超出则超出部分按每吨4元计费。请你帮忙算一下这个月的水费是多少。
Input
一行,一个实数,表示本月用水吨数
Output
一行,一个保留一位小数的实数,代表水费
Examples
Input
9.5
Output
26.0
Solution C++
#include <iostream> #include <cstdio> using namespace std; int main() { double cost,ans; cin>>cost; if(cost<=8) { ans=2.5*cost; } else { ans=2.5*8+(cost-8)*4; } printf("%.1lf\n",ans); return 0; }