摘要: 新年快到了,“猪头帮协会”准备搞一个聚会,已经知道现有会员N人,把会员从1到N编号,其中会长的号码是N号,凡是和会长是老朋友的,那么该会员的号码肯定和N有大于1的公约数,否则都是新朋友,现在会长想知道究竟有几个新朋友?请你编程序帮会长计算出来。 Input第一行是测试数据的组数CN(Case num 阅读全文
posted @ 2017-08-02 09:12 山杉三 阅读(123) 评论(0) 推荐(0) 编辑
摘要: Given two sequences of numbers : a11, a22, ...... , aNN, and b11, b22, ...... , bMM (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a numbe 阅读全文
posted @ 2017-08-01 19:20 山杉三 阅读(198) 评论(0) 推荐(0) 编辑
摘要: B君和G君聊天的时候想到了如下的问题。 给定自然数l和r ,选取2个整数x,y满足l <= x <= y <= r ,使得x|y最大。 其中|表示按位或,即C、 C++、 Java中的|运算。 Input包含至多10001组测试数据。 第一行有一个正整数,表示数据的组数。 接下来每一行表示一组数据, 阅读全文
posted @ 2017-08-01 10:55 山杉三 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了! 做好“一件”事情尚且不易,若想永远成功而总从不失败,那更是难上加难了,就像花钱总是比挣钱容易的道理一样。 话虽这样说,我还是要告诉大家,要想失败到一定程度也是不容易的。比如,我高中的时候,就有一个神奇的女生,在英语考试的时候,竟然把 阅读全文
posted @ 2017-07-31 15:39 山杉三 阅读(175) 评论(0) 推荐(0) 编辑
摘要: As we all know the Train Problem I, the boss of the Ignatius Train Station want to know if all the trains come in strict-increasing order, how many or 阅读全文
posted @ 2017-07-31 15:09 山杉三 阅读(143) 评论(0) 推荐(0) 编辑
摘要: There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must hide in one of the holes. A wolf searches the rabbit in anticlo 阅读全文
posted @ 2017-07-30 21:11 山杉三 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 监狱有连续编号为1...N的N个房间,每个房间关押一个犯人,有M种宗教,每个犯人可能信仰其中一种。如果相邻房间的犯人的宗教相同,就可能发生越狱,求有多少种状态可能发生越狱 Input 输入两个整数M,N.1<=M<=10^8,1<=N<=10^12 Output 可能越狱的状态数,模100003取余 阅读全文
posted @ 2017-07-30 20:59 山杉三 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Given a specified total t and a list of n integers, find all distinct sums using numbers from the list that add up to t. For example, if t=4, n=6, and 阅读全文
posted @ 2017-07-30 18:20 山杉三 阅读(418) 评论(0) 推荐(0) 编辑
摘要: A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacen 阅读全文
posted @ 2017-07-30 10:33 山杉三 阅读(902) 评论(0) 推荐(0) 编辑
摘要: 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路? Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数 阅读全文
posted @ 2017-07-30 10:18 山杉三 阅读(155) 评论(0) 推荐(0) 编辑