开始的时候题意看错了。。以为只能换乘一次车,其实是可以无限换的。。现实中谁会这么蛋疼,能打到车就不错了。。
#include<stdio.h>
int main()
{
int n;
while (scanf("%d", &n), n)
{
double res;
if (n <= 4)
res = 10.0;
else if (n <= 8)
res = 10.0 + (n - 4) * 2;
else if (n % 8 <= 4)
res = n / 8 * 18 + n % 8 * 2.4;
else
res = n / 8 * 18 + 10.0 + (n % 8 - 4) * 2;
double decimal = res - (int) res;
if (decimal > 0)
printf("%.1lf\n", res);
else
printf("%.0lf\n", res);
}
return 0;
}