第一次见到这种形式,推了两步就被卡住了。没想到还能这么迁移QAQ,真强! 题目设 $f(i)$为第$i$项斐波那契数列 要求计算 $$ans=\prod_{i=1}^n \prod_{j=1}^m f(gcd(i,j))$$ 枚举$d=gcd$得到 $$ans=\prod_{d=1}^n f(d)^ ...
分类:
其他好文 时间:
2017-12-10 23:01:03
阅读次数:
191
基本讲解: 1.UTF-8国际编码,GBK中文编码。GBK包含GB2312,即如果通过GB2312编码后可以通过GBK解码,反之可能不成立; 2、web tomcat:默认是ISO8859-1,不支持中文的 3.java.nio.charset.Charset.defaultCharset() 获得 ...
分类:
Web程序 时间:
2017-12-10 14:44:18
阅读次数:
242
筛选法 求出n以内的素数,最快的应该是筛选法。 筛选法的思路是: 要求10000以内的素数,把1-10000都列出来,1不是素数,划掉;2是素数,所有2的倍数都不是素数,划掉;取出下一个幸存的数,划掉它的所有倍数;直到所有素数找完为止。 这种做法的空间复杂度是O(n),时间复杂度O(n/logn)。 ...
分类:
其他好文 时间:
2017-12-10 12:45:56
阅读次数:
181
1 #include 2 #include 3 using namespace std; 4 int num[100000]; 5 long long prime[5000001]; 6 bool is_prime[10000001]; 7 int N,M; 8 int cnt=1; 9 int m... ...
分类:
其他好文 时间:
2017-12-09 18:07:48
阅读次数:
165
显然只需要能跑到第二个因子就赢了 需要特判非平凡因子 常数优化:不用求出所有因子,跑完第二个素数就行了 C++ include using namespace std; typedef long long ll; const int maxn = 233; ll n,cnt; ll prime[ma ...
分类:
其他好文 时间:
2017-12-09 13:10:57
阅读次数:
183
Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For exa ...
分类:
其他好文 时间:
2017-12-06 14:35:22
阅读次数:
139
Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, ...
分类:
其他好文 时间:
2017-12-06 14:21:49
阅读次数:
100
题目链接 http://poj.org/problem?id=1258 题意 有n个农场,现在要在n个农场之间铺设光纤使得n个农场连接起来,求铺设光纤的最短距离。 思路 最小生成树问题,使用Prime算法或者Kruskal算法解决。 代码 Prime算法: Kruskal算法: ...
分类:
Web程序 时间:
2017-12-03 22:46:52
阅读次数:
248
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1879 思路 这题和hdoj1102很像,图中的有一些路已经修好了,对于这些已经修好的路,我们令还需要修的长度为0即可,然后进行Prime算法或者Kruskal算法。 代码 Prime算法: Kruska ...
分类:
其他好文 时间:
2017-12-03 21:53:07
阅读次数:
240
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1102 题意 有n个村庄(编号1~n),给出n个村庄之间的距离,开始时n个村庄之间已经有了q条路,现在需要修一条路,这条路连接起所有的村庄,求在已经存在的路径的基础上,最少还需要修多长的路。 思路 普通最 ...
分类:
其他好文 时间:
2017-12-03 17:21:32
阅读次数:
114