2012年5月5日

并查集<转>

摘要: 来看一个实例,杭电1232畅通工程 http://acm.hdu.edu.cn/showproblem.php?pid=1232首先在地图上给你若干个城镇,这些城镇都可以看作点,然后告诉你哪些对城镇之间是有道路直接相连的。最后要解决的是整幅图的连通性问题。比如随意给你两个点,让你判断它们是否连通,或者问你整幅图一共有几个连通分支,也就是被分成了几个互相独立的块。像畅通工程这题,问还需要修几条路,实质就是求有几个连通分支。如果是1个连通分支,说明整幅图上的点都连起来了,不用再修路了;如果是2个连通分支,则只要再修1条路,从两个分支中各选一个点,把它们连起来,那么所有的点都是连起来的了;如果是3个 阅读全文

posted @ 2012-05-05 09:49 L_S_X 阅读(151) 评论(0) 推荐(0) 编辑

2012年4月27日

Leftmost Digit

摘要: Problem DescriptionGiven a positive integer N, you should output the leftmost digit of N^N.InputThe input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.Each test case contains a single positive integer N(1<=N& 阅读全文

posted @ 2012-04-27 19:57 L_S_X 阅读(117) 评论(0) 推荐(0) 编辑

The area

摘要: Problem DescriptionIgnatius bought a land last week, but he didn't know the area of the land because the land is enclosed by a parabola and a straight line. The picture below shows the area. Now given all the intersectant points shows in the picture, can you tell Ignatius the area of the land?No 阅读全文

posted @ 2012-04-27 18:47 L_S_X 阅读(348) 评论(0) 推荐(0) 编辑

Rightmost Digit

摘要: Problem DescriptionGiven a positive integer N, you should output the most right digit of N^N.InputThe input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.Each test case contains a single positive integer N(1<= 阅读全文

posted @ 2012-04-27 17:08 L_S_X 阅读(180) 评论(0) 推荐(0) 编辑

Largest prime factor

摘要: Problem DescriptionEverybody knows any number can be combined by the prime number.Now, your task is telling me what position of the largest prime factor.The position of prime 2 is 1, prime 3 is 2, and prime 5 is 3, etc.Specially, LPF(1) = 0.InputEach line will contain one integer n(0 < n < 100 阅读全文

posted @ 2012-04-27 16:56 L_S_X 阅读(473) 评论(0) 推荐(0) 编辑

导航