zoj 3693 Happy Great BG

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

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

 1/* ***********************************************
 2Author :111qqz
 3Created Time :2016年02月18日 星期四 15时16分59秒
 4File Name :code/zoj/3693.cpp
 5************************************************ */
 6
 7#include <cstdio>
 8#include <cstring>
 9#include <iostream>
10#include <algorithm>
11#include <vector>
12#include <queue>
13#include <set>
14#include <map>
15#include <string>
16#include <cmath>
17#include <cstdlib>
18#include <ctime>
19#define fst first
20#define sec second
21#define lson l,m,rt<<1
22#define rson m+1,r,rt<<1|1
23#define ms(a,x) memset(a,x,sizeof(a))
24typedef long long LL;
25#define pi pair < int ,int >
26#define MP make_pair
27
28using namespace std;
29const double eps = 1E-8;
30const int dx4[4]={1,0,0,-1};
31const int dy4[4]={0,-1,1,0};
32const int inf = 0x3f3f3f3f;
33int n,k;
34double ans,w;
35int dblcmp(double d)
36{
37    return d<-eps?-1:d>eps;
38}
39int main()
40{
41	#ifndef  ONLINE_JUDGE 
42	freopen("code/in.txt","r",stdin);
43  #endif
44
45	while (~scanf("%d %lf %d",&n,&w,&k))  //认真读题
46	{
47	    if (dblcmp(w)==0)
48	    {
49		puts("0.00");
50		continue;
51	    }
52	    n = n + 2;
53	    n = n-n/k;
54	    ans = n*w;
55	    ans = ans * 50;
56	    printf("%.2f\n",int(ans+0.5)*1.0/100);
57	}
58
59  #ifndef ONLINE_JUDGE  
60  fclose(stdin);
61  #endif
62    return 0;
63}