现在的位置: 首页 > 综合 > 正文

ZOJ 3693-进位

2014年01月20日 ⁄ 综合 ⁄ 共 1484字 ⁄ 字号 评论关闭

H - Happy Great BG

Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu

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 andFancy 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 Louis 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

关键是读懂这句话: please take care that the minimum monetary unit of RMB is fen (0.01 yuan).

也就是要进位到小数点后两位,比如3.985,就要进位到3.99


#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <stdio.h>

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;
}

抱歉!评论已关闭.