您的位置:首页 > 移动开发

zoj-3693-Happy Great BG

2016-05-04 22:44 609 查看
Description

The summer training of ZJU ICPC in July is about to end. To celebrate this great and happy day, the coaches of ZJU ICPC Team Navi and Fancy decided to BG everyone! Beside the two coaches, there are N participants. Those participants are divided into four groups to make problems for other groups.



After a brief discussion, they decided to go to Lou Wai Lou and have a great lunch. The cost for each person to have a meal in Lou Wai Lou is W yuan. Though it is very expensive, there is a special discount that Lou Wai Lou provided: for every K persons, one of them can have a free meal.

Navi and Fancy will equally pay all the cost for this great BG. Please help them to calculate how much money they each need to pay. By the way, please take care that the minimum monetary unit of RMB is fen (0.01 yuan).

Input

There are multiple test cases (no more than 100).

For each test case, there is only one line which contains three numbers N (1 <= N <= 100), W (0 <= W <= 10000) and K (1 < = K <= 100).

Output

For each test case, output the money a coach need to pay, rounded into 0.01 yuan.

Sample Input

3 70 3

32 999 1

Sample Output

140.00

0.00

就是n个人两个教练去才吃饭,没k个人免一个单,然后问你每个教练花的钱。直接模拟就好,但是浮点数哪里有点没搞定,Output Limit Exceeded了两发

#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
using namespace std;

int N, K;
double W;
int main () {
while (scanf("%d%lf%d", &N, &W, &K) != EOF) {
int ans = 0;
double sum  = 0;
N += 2;
ans = N / K;
N -= ans;
sum = N * W;
sum = sum / 2.0;
sum = (double)floor(sum * 100.0 + 0.9) / 100.0;
printf("%.2lf\n", sum);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: