ZOJ 3693 Happy Great BG(浮点数的进位)

Happy Great BG

Time Limit: 2 Seconds       Memory Limit: 65536 KB

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

Author: JIANG, Kai
Contest: ZOJ Monthly, March 2013

 

 

虽然说这是一道非常水非常水的题目,但是还是WA了我9次,应该说很多人被坑了= =

主要是要看懂这一句话 please take care that the minimum monetary unit of RMB is fen (0.01 yuan).

意思就是说分以后的要进位,例如3.461就要进位到3.47

一开始是没有看到两个教练平摊WA了,后来看到是输入lf觉得输入应该不止只有小数点后面两位,没想到还是贡献这么多WA。

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<stack>
#include<stdlib.h>
#include<algorithm>
#define LL __int64
using namespace std;
const double EPS=1e-8;
int main()
{
    int n,k;
    double w,ans;
    while(scanf("%d %lf %d",&n,&w,&k)!=EOF)
    {
        int num=(n+2)-(n+2)/k;
        ans=num*w/2*100;
        if(ans-(int)ans>EPS)
            ans=(int)ans+1;
        printf("%.2f\n",ans/100);
    }
    return 0;
}
View Code

 

转载于:https://www.cnblogs.com/clliff/p/4134402.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值