摘要: Problem Description某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路?Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( int father[1001],rank[1001];int find(int x)//寻找x的父节点{ if(x!=father[x]) father[x]=find(father[x]);//回溯时路径压缩 ... 阅读全文
posted @ 2014-01-05 17:28 段少 阅读(127) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionMr Wang wants some boys to help him with a project. Because the project is rather complex, the more boys come, the better it will be. Of course there are certain requirements.Mr Wang selected a room big enough to hold the boys. The boy who are not been chosen has to leave the room 阅读全文
posted @ 2014-01-05 17:22 段少 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 并查集是若干个不想交的集合,能够实现较快的合并和判断元素所在集合的操作,应用很多,如求无向图的连通分量个数等。并查集的精髓就是它的三种操作:初始化、查找、合并int father[MAX];//father[x]表示x的父节点int rank[MAX];//rank[x]表示x的秩void Make_set(int x){ father[x]=x; rank[x]=0;}int find(int x)//查找元素所在的父节点,回溯时压缩路径{ if(x!=father[x]) father[x]=find(father[x]); return father... 阅读全文
posted @ 2014-01-05 14:27 段少 阅读(209) 评论(0) 推荐(0) 编辑
摘要: DescriptionSevere acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best strategy is to separate the suspects from others.In the Not-Spreading-Your-Sickness University (NSYSU), t 阅读全文
posted @ 2014-01-05 14:11 段少 阅读(152) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionEddy是个ACMer,他不仅喜欢做ACM题,而且对于Ranklist中每个人的ac数量也有一定的研究,他在无聊时经常在纸上把Ranklist上每个人的ac题目的数量摘录下来,然后从中选择一部分人(或者全部)按照ac的数量分成两组进行比较,他想使第一组中的最小ac数大于第二组中的最大ac数,但是这样的情况会有很多,聪明的你知道这样的情况有多少种吗?特别说明:为了问题的简化,我们这里假设摘录下的人数为n人,而且每个人ac的数量不会相等,最后结果在64位整数范围内.Input输入包含多组数据,每组包含一个整数n,表示从Ranklist上摘录的总人数。Outpu 阅读全文
posted @ 2014-01-05 11:33 段少 阅读(140) 评论(0) 推荐(0) 编辑
摘要: DescriptionA Compiler Mystery: We are given a C-language style for loop of typefor (variable = A; variable != B; variable += C) statement;I.e., a loop which starts by setting variable to value A and while variable is not equal to B, repeats statement followed by increasing the variable by C. We wan. 阅读全文
posted @ 2013-12-23 07:39 段少 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 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#incl 阅读全文
posted @ 2013-12-22 23:07 段少 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 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#includ 阅读全文
posted @ 2013-12-22 22:58 段少 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Description两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰面的。为了帮助这两只乐观的青蛙,你被要求写一个程序来判断这两只青蛙是否能够碰面,会在什么时候碰面。我们把这两只青蛙分别叫做青蛙A和青蛙B,并且规定纬度线上东经0度处为原点,由东往西为正方向,单位长度1米,这样我 阅读全文
posted @ 2013-12-22 00:31 段少 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 我原来觉得自己就是在讲台上讲不好话的人,今天给大一的将题目,感觉也没自己的想的那么难,尽管普通话不标准,尽管很多人没听懂,但自我感觉还挺好的,以后多多锻炼,以后说不定我也能像别人一样,在上面收放自如。呵呵... 阅读全文
posted @ 2013-12-21 22:39 段少 阅读(106) 评论(0) 推荐(0) 编辑