zoj 3693 Happy Great BG

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3693 题意: n+2个人取吃饭,每人w元,每k个人可以少付一个人的钱,问最后两个教练每人要付多少钱。

思路:贪心。坑点在读题。。选手n个人,不要忘记两个教练,以及,钱数是两个教练平分。

/* ***********************************************
Author :111qqz
Created Time :2016年02月18日 星期四 15时16分59秒
File Name :code/zoj/3693.cpp
************************************************ */
 1#include <cstdio>
 2#include <cstring>
 3#include <iostream>
 4#include <algorithm>
 5#include <vector>
 6#include <queue>
 7#include <set>
 8#include <map>
 9#include <string>
10#include <cmath>
11#include <cstdlib>
12#include <ctime>
13#define fst first
14#define sec second
15#define lson l,m,rt<<1
16#define rson m+1,r,rt<<1|1
17#define ms(a,x) memset(a,x,sizeof(a))
18typedef long long LL;
19#define pi pair < int ,int >
20#define MP make_pair
 1using namespace std;
 2const double eps = 1E-8;
 3const int dx4[4]={1,0,0,-1};
 4const int dy4[4]={0,-1,1,0};
 5const int inf = 0x3f3f3f3f;
 6int n,k;
 7double ans,w;
 8int dblcmp(double d)
 9{
10    return d<-eps?-1:d>eps;
11}
12int main()
13{
14	#ifndef  ONLINE_JUDGE 
15	freopen("code/in.txt","r",stdin);
16  #endif
 1	while (~scanf("%d %lf %d",&n,&w,&k))  //认真读题
 2	{
 3	    if (dblcmp(w)==0)
 4	    {
 5		puts("0.00");
 6		continue;
 7	    }
 8	    n = n + 2;
 9	    n = n-n/k;
10	    ans = n*w;
11	    ans = ans * 50;
12	    printf("%.2f\n",int(ans+0.5)*1.0/100);
13	}
1  #ifndef ONLINE_JUDGE  
2  fclose(stdin);
3  #endif
4    return 0;
5}