http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2256
n*2.5 <=10+(n-4)*2 n<=4
n*2.5 > 10+(n-4)*2 8>=n>=5
每8km一判断
就那就%8 判断余数
前8km特判
注意小数点的要求
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
#define INF 99999999
#define MIN(a,b) (a>b?b:a)
typedef long long LL;
int main()
{
int n;
while(cin>>n&&n)
{
if(n<=4)
cout<<10<<endl;
else if(n<=8)
cout<<10+(n-4)*2<<endl;
else
{
LL t=n/8*18;
n%=8;
if(n>=5)
{
t+=10+(n-4)*2;
cout<<t<<endl;
}
else
{
double s=n*2.4;
if(s!=0)
{
s+=t;
cout<<fixed<<setprecision(1)<<s<<endl;
}
else
cout<<t<<endl;
}
}
}
return 0;
}