hdu 4112 Break the Chocolate 贪心】的更多相关文章

Break the Chocolate Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4112 Description Benjamin is going to host a party for his big promotion coming up.Every party needs candies, chocolates and beer, and of cour…
规律题: #include<stdio.h> #include<math.h> #define eps 1e-8 int main() { int _case; int n,m,k,i; __int64 ans1; int ans2,ans; scanf("%d",&_case); ;i<=_case;i++) { scanf("%d%d%d",&n,&m,&k); printf("Case #…
题意:要把一块n*m*k的巧克力分成1*1*1的单元,有两种操作方式:1,用手掰(假设力量无穷大),每次拿起一块,掰成两块小的:2,用刀切(假设刀无限长),可以把多块摆在一起,同时切开.问两种方式各需多少次操作才能完成任务. 分析:用手掰很明显是(n*m*k-1)次操作.用刀切注意不是((n-1)+(m-1)+(k-1))次操作,这只是不动原巧克力的操作数.举个例子:1*1*4的巧克力,用刀切,按上面说的要3次操作,实际上只需2次.所以不管是长宽高,都只需要[log2n](或m,k)次操作. 注…
题意:有一块n*m*k的巧克力,最终需要切成n*m*k个1*1*1的块,问用以下两种方法最少掰多少次能达到目的: 1.用手掰:每次只能拿出一块来掰:2.用刀切:可以把很多已经分开的块摞在一起一刀切下来 分析: 1.用手掰,需要n*m*k-1次. 2.用刀切,可以分别考虑长宽高,计算长宽高分别切成单位长度所需要的最少次数,相加即可. 二分切,可得最少次数.规律为,长度为x最少需切ceil(log2(x))次. #include<cstdio> #include<algorithm>…
Break the Chocolate Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4662    Accepted Submission(s): 1501 Problem Description Benjamin is going to host a party for his big promotion coming up. E…
Break the Chocolate Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/546/problem/A Description A soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so…
hdu 4825 Xor Sum(trie+贪心) 刚刚补了前天的CF的D题再做这题感觉轻松了许多.简直一个模子啊...跑树上异或x最大值.贪心地让某位的值与x对应位的值不同即可. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #define CLR(a,b) memset((a),(b),sizeof(…
Elegant Construction 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5813 Description Being an ACMer requires knowledge in many fields, because problems in this contest may use physics, biology, and even musicology as background. And now in this prob…
题目链接:pid=3697" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=3697 Problem Description     A new Semester is coming and students are troubling for selecting courses. Students select their course on the web course system. There…
第一题;http://acm.hdu.edu.cn/showproblem.php?pid=1257 贪心与dp傻傻分不清楚,把每一个系统的最小值存起来比较 #include<cstdio> using namespace std; ],b[]; int main() { int n,i,j; while (~scanf("%d",&n)) { ; b[]=-; ;i<n;i++) { scanf("%d",&a[i]); ;j&l…