01 2014 档案

摘要:Problem DescriptionThe Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 #include#includeint s[32767],num=1;bool u[32767];void preper(){ int i,j; memset(u,true,sizeof(u)); for(i=2;i32767) break; u[i*s[j]]=false; if(i%... 阅读全文
posted @ 2014-01-21 21:10 段少 阅读(182) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionEverybody in the Prime Land is using a prime base number system. In this system, each positive integer x is represented as follows: Let {pi}i=0,1,2,... denote the increasing sequence of all prime numbers. We know that x > 1 can be represented in only one way in the form of prod 阅读全文
posted @ 2014-01-21 20:45 段少 阅读(404) 评论(0) 推荐(0) 编辑
摘要:Problem Description省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。Input测试输入包含若干测试用例。每个测试用例的第1行给出评估的道路条数 N、村庄数目M ( #includeusing namespace std;typedef struct{ int st,ed; int len;}enodge;int cmp(enodge a,enodge b){ return ... 阅读全文
posted @ 2014-01-09 13:05 段少 阅读(207) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionThere are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your university believe in. You know that there are n students in your university (0 int father[50001 阅读全文
posted @ 2014-01-08 17:15 段少 阅读(176) 评论(0) 推荐(0) 编辑
摘要:#includetypedef struct{ int adj;//某定点与已构造好的部分生成树的顶点之间权值最小的顶点 int lowcost;//某定点与已构造好的部分生成树的顶点之间的最小权值}point;point close[101];//辅助数组int d[101][101];int main(){ int n,i,a,b,sum,j,min,k,m; while(scanf("%d",&n)!=EOF) { if(n==0) break; sum=0;//记录最小生成树的总路径 m=n*(n-1)/2; ... 阅读全文
posted @ 2014-01-08 10:23 段少 阅读(175) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionNowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now.The game can be played by two or more than two players. It consists of a chessboard(棋盘)and some 阅读全文
posted @ 2014-01-07 21:23 段少 阅读(149) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionThe highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The 阅读全文
posted @ 2014-01-07 14:55 段少 阅读(152) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionBoudreaux and Thibodeaux are on the road again . . ."Boudreaux, we have to get this shipment of mudbugs to Baton Rouge by tonight!""Don't worry, Thibodeaux, I already checked ahead. There are three underpasses and our 18-wheeler will fit through all of them, so 阅读全文
posted @ 2014-01-07 14:36 段少 阅读(197) 评论(0) 推荐(0) 编辑
摘要:Problem Description2100年,科学家们登上月球,在那里建造了很多城镇,并且大部分建在了空中,但还没有铺设道路,无法满足人们的生活需要。为了尽快完成铺设道路任务,他们必须找出一种总路程最短的方案使每个城镇之间都相互可达(并不要求直接可达,通过其它城镇中转也可)。你知道他们方案的总路程数吗?Input第一行是一个正整数T,代表数据的组数,每组数据第一行是一个正整数N,代表有N个城镇,接下来N行每行三个正整数xi,yi,zi代表第i个城镇的坐标。(1#includetypedef struct{ int adj;//记录已构造的生成树的顶点 double lowcos... 阅读全文
posted @ 2014-01-07 10:10 段少 阅读(156) 评论(0) 推荐(0) 编辑
摘要:Problem Description大武汉一直流传着这样一个传说:玩在武大,学在华科,爱在华师,吃在湖工。。。大武汉有N所高校,现在打算在他们之间建立一个局域网,使它们之间能够相互连通。但是铺网线是要钱的。。。怎样才能找到一个最省钱的方法呢。Input输入包含多组测试数据第一行给出学校的数目N,(3 int a[111][111];typedef struct{ int adj;//保存符合要求的点 int lowcost;//某顶点与已构造好的部分生成树的顶点之间的最小权值}closeedge;//辅助结构体closeedge close[111];//辅助数组int main... 阅读全文
posted @ 2014-01-07 09:15 段少 阅读(271) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionThere must be many A + B problems in our HDOJ , now a new one is coming.Give you two hexadecimal integers , your task is to calculate the sum of them,and print it in hexadecimal too.Easy ? AC it !InputThe input contains several test cases, please process to the end of the file.Eac 阅读全文
posted @ 2014-01-06 14:38 段少 阅读(410) 评论(0) 推荐(1) 编辑
摘要:DescriptionAn earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the network were all broken. The computers are repaired one by one, and the network gradually 阅读全文
posted @ 2014-01-06 13:35 段少 阅读(187) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionIn many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of digits in the factorial of the number.InputInput c 阅读全文
posted @ 2014-01-06 11:19 段少 阅读(123) 评论(0) 推荐(0) 编辑
摘要:Problem Description约19世纪末,在欧州的商店中出售一种智力玩具,在一块铜板上有三根杆,最左边的杆上自上而下、由小到大顺序串着由64个圆盘构成的塔。目的是将最左边杆上的盘全部移到右边的杆上,条件是一次只能移动一个盘,且不允许大盘放在小盘的上面。现在我们改变游戏的玩法,不允许直接从最左(右)边移到最右(左)边(每次移动一定是移到中间杆或从中间移出),也不允许大盘放到下盘的上面。Daisy已经做过原来的汉诺塔问题和汉诺塔II,但碰到这个问题时,她想了很久都不能解决,现在请你帮助她。现在有N个圆盘,她至少多少次移动才能把这些圆盘从最左边移到最右边?Input包含多组数据,每次输入一 阅读全文
posted @ 2014-01-05 18:01 段少 阅读(251) 评论(0) 推荐(0) 编辑
摘要: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 段少 阅读(128) 评论(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 段少 阅读(148) 评论(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 段少 阅读(210) 评论(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 段少 阅读(153) 评论(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 段少 阅读(143) 评论(0) 推荐(0) 编辑