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
题意简单,但是坑多。。。。
注意到题目说两个教练,答案输出的是每个教练应支付的钱。
答案保留2位小数,但是我们应该计算到小数点后3位,付的钱只能多,不能少,所以应该加0.004进位。
#include<stdio.h> #include<algorithm> #include<map> #include<string.h> #include<math.h> #define lson l,m,rt <<1 #define rson m+1,r,rt << 1 | 1 #define LL long long #define INF 0x3f3f3f3f const int maxn = 100005; using namespace std; int main() { int n,k; double w; while(~scanf("%d%lf%d",&n,&w,&k)) { printf("%.2lf\n",(n+2-(n+2)/k)*w/2+0.004); } return 0; }