Midlife for many is a time of transition, a time of questioning and a time of change, not just physically, but emotionally and mentally. It’s when you...
分类:
其他好文 时间:
2014-07-31 02:18:35
阅读次数:
325
问题描述:
You are climbing a stair case. It takes n steps to reach to the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
解题思路:
这是一个典型的斐波那契数列,对于...
分类:
其他好文 时间:
2014-07-31 00:02:55
阅读次数:
243
题目描述 Give you a lot of positive integers, just to find out how many prime numbers there are.. In each case, there is an integer N representing the num...
分类:
其他好文 时间:
2014-07-30 23:35:35
阅读次数:
300
这道题跟HDU 1213 How Many Tables 并查集非常接近,都是赤裸裸的并查集的题。
思路:假设还需要建n-1条路,每并一次就自减1。
优化:先用数组储存m组数,然后只对这些节点的根节点
赋初值fa[u[i]]=u[i];fa[v[i]]=v[i];...
分类:
其他好文 时间:
2014-07-30 20:56:54
阅读次数:
215
Description
After coding so many days,Mr Acmer wants to have a good rest.So travelling is the best choice!He has decided to visit n cities(he insists on seeing all the cities!And he does not mind w...
分类:
其他好文 时间:
2014-07-30 17:37:14
阅读次数:
306
Find DigitsProblem StatementGiven a number you have to print how many digits in that number exactly divides that number.Input formatThe first line con...
分类:
其他好文 时间:
2014-07-30 11:55:13
阅读次数:
250
Elegant handbags are still many children and designer bags. These designer handbags are considered to be among the list of young mothers intelligent a...
分类:
其他好文 时间:
2014-07-30 11:52:43
阅读次数:
296
Ubiquitous ReligionsTime Limit:5000MSMemory Limit:65536KTotal Submissions:23997Accepted:11807DescriptionThere are so many different religions in the w...
分类:
其他好文 时间:
2014-07-30 09:45:43
阅读次数:
198
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1213典型的并查集,属于水题吧,但学会了路径压缩。 1 /*非递归,非路径压缩*/ 2 #include 3 const int maxn=1000+5; 4 int fa[maxn]; 5 void i...
分类:
其他好文 时间:
2014-07-29 20:58:42
阅读次数:
217
这是一道简单的并查集的题目,跟UVA 10608 Friends 差不多。
对于统计桌子的数目,我用了两种方法:
1、先将桌子数目初始化为n,然后合并一次就减一张。
2、先将朋友们分好组,在统计 fa[i]=i 的这些根节点有多少即为所求的桌子数。...
分类:
其他好文 时间:
2014-07-29 18:10:42
阅读次数:
213