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了两发
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; }
相关文章推荐
- 浅谈Android系统开发中NDK LOG的使用
- Android--design--DrawerLayout
- 友盟社会化Android组件之第三方登录
- Android定位和地图开发实例
- iOS 计算文字高度
- Android 原型模式
- Android开发超级工具介绍traceview
- Android-SQLiteDatabase数据存储
- Android 之 Notification
- Android自定义视图二:如何绘制内容
- 如何在调试Window App时,触发 Suspending ,Resuming 等事件
- 学习Unity射线的创建使用
- 如何在调试Window App时,触发 Suspending ,Resuming 等事件
- Android开发实现发送短信验证码(使用第三方服务器Bmob)
- Appium测试环境搭建实践
- Andriod mutidex相关的文章
- MAC下创建Android、iOS模拟器的方法
- Android客户端支付功能,只用第三方支付接口
- Android倒计时定时器CountDownTimer的用法
- swift 基本语法(二)