08 2017 档案
摘要:题意就是求n的k次方的前三位和后三位 - 后三位快速幂取模就行。 - 前三位,首先pow(n,k)=pow(10,k*lg(n)),此时可以看出pow(n,k)的值的位数是由k *lg(n)的整数部分决定,而值是由其小数部分决定,因此只取前三位的话让k *lg(n)的...
阅读全文
摘要:In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers: In this problem, you are gi...
阅读全文
摘要:Goldbach's conjecture is one of the oldest unsolved problems in number theory and in all of mathematics. It states:Every even integer,...
阅读全文
摘要:Description Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her...
阅读全文
摘要:题意就是给出棍子的长度和n个切点,让你把它切成n+1段,每次切时花费价值为此时棍子的长度,问怎样切才能使最终花费最少。 区间dp,就是指一整段区间的最优值可以由其中几段小区间的最优值来决定,因此次类问题一般都是从小到大枚举区间的大小,然后再求每一个该大小的区间的最优值...
阅读全文
摘要:题目:https://odzkskevi.qnssl.com/f85205c68ae5f131a579c799f71b7b69?v=1502173334 旅行商问题描述:平面上n个点,确定一条连接各点的最短闭合旅程。这个解的一般形式为NP的(在多项式时间内可以求出)J...
阅读全文
摘要:Problem Description It has recently been discovered how to run open-source software on the Y-Crate gaming device. A number of enterpri...
阅读全文
摘要:题目:https://odzkskevi.qnssl.com/95fc8c37ba05359d81df6779e817c236?v=1501937229因为q很小,所以直接枚举所有的方案就行。 首先求不用方案时的最小生成树,然后每次枚举方案时只需考虑初次最小生成树中的...
阅读全文
摘要:题目:https://odzkskevi.qnssl.com/8e16f8701018d0e3529ac3ca319e1f67?v=1502277241 最简单的kruskal,主要参考紫书代码 kruskal算法就是先给边按权值大小排序,然后从小到大遍历,用并查集判...
阅读全文
摘要:A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = #include #in...
阅读全文
摘要:Problem Description John is a manager of a CPU chip factory, the factory produces lots of chips everyday. To manage large amounts of p...
阅读全文
摘要:DescriptionYou have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. F...
阅读全文
摘要:回文串是指aba、abba、cccbccc、aaaa这种左右对称的字符串。输入一个字符串Str,输出Str里最长回文子串的长度。Input 输入Str(Str的长度 #include #include #include using namespace std...
阅读全文
摘要:The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter ‘e’. He was a member of the Oulipo g...
阅读全文
摘要:多重背包可转化为01背包,首先将件数C二进制分解为多个件数的集合,这些件数可以组合成任意 小于等于C的数字,而且不会重复。 如7 7=111,可以分解为100,010,001,这三个数可以组合为任意小于等于7的数,而且每种组合都会得到不同的数。 13 13...
阅读全文