Hanoi Tower Troubles Again! Problem Description People stopped moving discs from peg to peg after they know the number of steps needed to complete the entire task. But on the other hand, they didn't not stopped thinking about similar puzzles with the…
找规律的题目an=an-1+(i+i%2)/2*2; ;}…
水题,搞清楚hanoi的定义就好做了. /* 1329 */ #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #define MAXN 55 int b[MAXN]; int a[MAXN]; bool isSquare(int x) { int y = (int) sqrt(x*1.0); return y*y == x; } void init() { in…
Hanoi Tower Troubles Again! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 602    Accepted Submission(s): 418 Problem Description People stopped moving discs from peg to peg after they know the…
链接:ZOJ1239 Hanoi Tower Troubles Again! Description People stopped moving discs from peg to peg after they know the number of steps needed to complete the entire task. But on the other hand, they didn't not stopped thinking about similar puzzles with…
People stopped moving discs from peg to peg after they know the number of steps needed to complete the entire task. But on the other hand, they didn't not stopped thinking about similar puzzles with the Hanoi Tower. Mr.S invented a little game on it.…
题意:要把一块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)次操作. 注…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4614 题目大意:有n个空花瓶,有两种操作: 操作①:给出两个数字A,B,表示从第A个花瓶开始插花,插B朵花,输出第一个和最后一个插入的花瓶,如果任意花瓶都已经满了不能插花,则输出“Can not put any one.”. 操作②:给出两个数字A,B,表示清空第A~B个花瓶,并输出清空掉的花朵数目. 解题思路:线段树,关于操作②,很简单弄个sum表示区间空花瓶数,计算时清空掉的花朵数=区间长度-s…
链接: http://acm.hdu.edu.cn/showproblem.php?pid=4506 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=29096#problem/B 小明系列故事——师兄帮帮忙 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 3338    Ac…
题意:题目太长直接看链接 链接:点我 乱搞题 显然,一个人要想成功,必须大于等于最强的人的战斗力,所以我们从后往前看 这里直接拿例1解释,首先递减排个序 15,13,10,9,8 作差得2,3,1,1, 此时我们从10出发即可成功 同时也发现,战斗力逐渐递增和直接到某个值其实是等价的 于是我们假设战斗力是从15-13-10-9-8变化的,观察这种变化能否成功即可 由13到15,变化为2,则从13出发剩余战斗力至少得提高2 从10到13,战斗力要提高3,而k为3然后10小于m,即成功 看一下反例2…