摘要:描述先来看一个有趣的悖论:如果你随机从下面的选项中选出一个答案,选到正确答案的概率是多少?A.25% B.50% C.0% D.25%当你仔细理解了上面的悖论之后,下面问题来了,如果现在随便给你一组选项,你能判断出它们是否必然产生悖论吗?输入第一行输入一个整数T(T<=50),表示测试数据的组数每组测试数据的第一行是一个整数N,表示选项的个数,随后的一行有N个分数(ai/bi),表示N个选项的值(1<=N<=100000)。所有分数都以最简原分数表示(特别地,如果值是整数,则分母当作1),0<=ai,bi<=100000。输出如果产生悖论则输出Yes,否则输出No
阅读全文
摘要:描述The binary weight of a positive integer is the number of 1's in its binary representation.for example,the decmial number 1 has a binary weight of 1,and the decimal number 1717 (which is 11010110101 in binary) has a binary weight of 7.Give a positive integer N,return the smallest integer greate
阅读全文
摘要:苹果时间限制:3000 ms | 内存限制:65535 KB难度:2 描述ctest有n个苹果,要将它放入容量为v的背包。给出第i个苹果的大小和价钱,求出能放入背包的苹果的总价钱最大值。输入有多组测试数据,每组测试数据第一行为2个正整数,分别代表苹果的个数n和背包的容量v,n、v同时为0时结束测试,此时不输出。接下来的n行,每行2个正整数,用空格隔开,分别代表苹果的大小c和价钱w。所有输入数字的范围大于等于0,小于等于1000。输出对每组测试数据输出一个整数,代表能放入背包的苹果的总价值。样例输入3 31 12 13 10 0样例输出2思路:经典的0-1背包问题View Code 1 #in.
阅读全文
摘要:VF时间限制:1000 ms | 内存限制:65535 KB难度:2描述Vasya is the beginning mathematician. He decided to make an important contribution to the science and to become famous all over the world. But how can he do that if the most interesting facts such as Pythagor’s theorem are already proved? Correct! He is to think o
阅读全文
摘要:这是俺的第一个dp,虽然只是简单的斐波那契……………… 01串 时间限制:1000 ms | 内存限制:65535 KB 这是俺的第一个dp,虽然只是简单的斐波那契……………… 01串 时间限制:1000 ms | 内存限制:65535 KB ACM的zyc在研究01串,他知道某一01串的长度,但他
阅读全文
摘要:描述:A tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed edges between nodes satisfying the following properties. There is exactly one node, called the root, to which no directed edges point. Every node except the root
阅读全文
摘要:描述:动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说法是"2 X Y",表示X吃Y。 此人对N个动物,用上述两种说法,一句接一句地说出K句话,这K句话有的是真的,有的是假的。当一句话满足下列三条之一时,这句话就是假话,否则就是真话。 1) 当前的话与前面的某些真的话冲突,就是假话; 2) 当前的话中X或
阅读全文
摘要:来看一个实例,杭电1232畅通工程 http://acm.hdu.edu.cn/showproblem.php?pid=1232首先在地图上给你若干个城镇,这些城镇都可以看作点,然后告诉你哪些对城镇之间是有道路直接相连的。最后要解决的是整幅图的连通性问题。比如随意给你两个点,让你判断它们是否连通,或者问你整幅图一共有几个连通分支,也就是被分成了几个互相独立的块。像畅通工程这题,问还需要修几条路,实质就是求有几个连通分支。如果是1个连通分支,说明整幅图上的点都连起来了,不用再修路了;如果是2个连通分支,则只要再修1条路,从两个分支中各选一个点,把它们连起来,那么所有的点都是连起来的了;如果是3个
阅读全文
摘要: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&
阅读全文
摘要: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
阅读全文
摘要: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<=
阅读全文
摘要: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
阅读全文