Skip to main content
  1. Posts/

zoj 3693 Happy Great BG

·1 min
Note: This article is available in Chinese only. 本文暂无英文版本。 View original

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}

Related

codeforces 373 C. Counting Kangaroos is Fun

·1 min
http://codeforces.com/contest/373/problem/C 题意:n个袋鼠,每个袋鼠的size为a[i],一只袋鼠的size至少是另一只两倍时才能将它装下,被装下的袋鼠不能再装别的袋鼠且不能被看见。问能看见的袋鼠最少是多少。 思路:贪心。最多有n/2个袋鼠被装下。先排序,然后贪心即可。

uva 10785 The Mad Numerologist

·2 mins
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid;=8&page;=show_problem&problem;=1726 题意:给出26个大写字母的权值,要求构造一个长度为n(n不超过210)的字符串。并且满足奇数位置只能放元音字母,偶数位置只能放辅音字母,且每个元音字母最多放21次,每个辅音字母最多放5次,要求构造的字符串的权值之和最小,在权值最小的前提下字典序最小。

codeforces 12 C. Fruits

·1 min
http://codeforces.com/contest/12/problem/C 题意:有n个价格价格,m个要买的东西(可能有相同的种类,设为k种),把n个标签中拿出k个给个贴上。。。问最大价钱和最少价钱分别是多少。 思路:贪心。不过要按照map的value排序。。然后发现其实不用排序。。因为map的key值其实不影响。

codeforces 526 B Om Nom and Dark Park

·1 min
http://codeforces.com/contest/526/problem/B 题意:有一棵完全二叉树。每条边上有一定数量的路灯。问最少需要添加多少个路灯。使得根节点道叶子节点的每一条路径上的路灯数量一样。 思路:同叶子节点网上更新即可。

cf 596 B. Wilbur and Array

·1 min
http://codeforces.com/problemset/problem/596/B 题意:初始序列全为0,问经过多少次变换,能变成序列b。一次变换是指,选定一个i,从i一直到最后每个元素都增加1,或者每个元素都减少1. 思路:很容易发现。后面的变换补影响前面的变换。每一个数字可以唯一由之前的增加和减少次数决定。所以我们用两个变量,记录之前做的增加和减少变换的次数。然后扫一遍即可。