摘要: 给定空间里n(n<=1000)个点,假设任意三个点都不共线。 将任意两点之间的连线涂上红色或者黑色。 问3条边同色的三角形个数。 分析: 由于三角形总数C(n,3),所以求出异色三角形个数就求出了同色三角形个数。 我们发现这样的对应关系,一个异色三角形存在两个顶点,该三角形中与它们相邻的两边是不同色 阅读全文
posted @ 2016-08-23 23:51 Yan_Bin 阅读(618) 评论(0) 推荐(0)
摘要: Minimum Sum LCMLCM (Least Common Multiple) of a set of integers is defined as the minimum number, which is amultiple of all integers of that set. It i 阅读全文
posted @ 2016-08-23 22:36 Yan_Bin 阅读(246) 评论(0) 推荐(0)
摘要: Choose and divideThe binomial coefficient C(m; n) is defined asC(m; n) =m!(m 􀀀 n)! n!Given four natural numbers p, q, r, and s, compute the the resul 阅读全文
posted @ 2016-08-23 22:28 Yan_Bin 阅读(188) 评论(0) 推荐(0)
摘要: Colossal Fibonacci Numbers!Oooh...prettyThe i’th Fibonacci number f(i) is recursivelydefined in the following way:• f(0) = 0 and f(1) = 1• f(i + 2) = 阅读全文
posted @ 2016-08-23 22:06 Yan_Bin 阅读(206) 评论(0) 推荐(0)
摘要: map实例代码: 1 // UVa156 Ananagrams 2 // Rujia Liu 3 // 题意:输入一些单词,找出所有满足如下条件的单词:该单词不能通过字母重排得到输入文本中的另外一个单词 4 // 算法:把每个单词“标准化”,即全部转化为小写字母然后排序,然后放到map中进行统计 5 阅读全文
posted @ 2016-08-23 12:08 Yan_Bin 阅读(1108) 评论(0) 推荐(0)
摘要: 以point结构体为例 阅读全文
posted @ 2016-08-23 11:01 Yan_Bin 阅读(110) 评论(0) 推荐(0)
摘要: 以结构体point为例,成员变量x,y,定义加法和输出流方式。 阅读全文
posted @ 2016-08-23 10:59 Yan_Bin 阅读(146) 评论(0) 推荐(0)
摘要: 考虑这样一个题目: 输入的每行是若干整数,要求输出每行所有整数的和。 实例代码: 阅读全文
posted @ 2016-08-23 10:53 Yan_Bin 阅读(376) 评论(0) 推荐(0)
摘要: 1.set集合中如果存储string类,那么集合元素将按照字典序全部排好。 2.set集合的遍历: set<string>::iterator it; for(it = dict.begin() ; it != dict.end() ; it++) cout << *it << endl; 阅读全文
posted @ 2016-08-23 00:16 Yan_Bin 阅读(164) 评论(0) 推荐(0)
摘要: Andy’s First Dictionary Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him, as the number of words t 阅读全文
posted @ 2016-08-23 00:14 Yan_Bin 阅读(148) 评论(0) 推荐(0)