题意 给出a,b,n,已知f[1]=f[2]=1,f[i]=(a*f[i-1]+b*f[i-2]) mod 7 输出f[n] 数据范围1 8 using namespace std; 9 const int N=100;10 int f[N];11 12 int main()13 {14 ...
分类:
其他好文 时间:
2014-10-15 23:32:01
阅读次数:
326
# Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3...
分类:
编程语言 时间:
2014-10-15 23:13:51
阅读次数:
245
POJ2478_Farey Sequence【快速求欧拉函数】
题目大意:
给你一个数n,对于0 < a < b <= n,求真分数a/b的个数
思路:因为a/b为真分数,所以a和b互质。
求真分数a/b的个数。其实就是求0 < i <= n中,小于i的正整数中,
有多少个与i互质的数。累加起来就是真分数a/b的个数。
其实就是欧拉函数
因为n的规模为10^6,可用快速求欧拉函数的方法求得(类似于筛法求素数)。
根据推论:设P是素数,
若p是x的约数,则E(x*p)=E(x)*p.
若p不是x的约数...
分类:
其他好文 时间:
2014-10-15 23:10:51
阅读次数:
178
The set [1,2,3,…,n] contains a
total of n! unique permutations.
By listing and labeling all of the permutations in order,
We get the following sequence (ie, for n = 3):
"123""132""213""231""3...
分类:
其他好文 时间:
2014-10-15 19:33:41
阅读次数:
145
分块,v[i][j][k]表示第i块内第j位是k的元素数。非常好写。注意初始化要注意题意,①第i位是从右往左算的。②若x没有第i位,则用前导零补齐10位。比如103---->0000000103。 1 #include 2 #include 3 #include 4 using namespace ...
分类:
其他好文 时间:
2014-10-15 19:05:51
阅读次数:
245
这题关键是要理解数的顺序怎么通过递推得到。以题目中给出的n = 3为例:我们看到,总共是3! = 6 个数,123132213231312321以1、2和3开始的数各有两个(2!个),我们可以推广一下,对于n!个数,以1、2……n开头的数各有(n - 1)!个,而开头的数小的,总是排在前面。当我们要...
分类:
其他好文 时间:
2014-10-15 00:27:29
阅读次数:
125
题目出处:http://acm.hdu.edu.cn/showproblem.php?pid=5064题意:给定n个数,求满足以下两个条件的子序列的最大长度: (1)C1 2 #include 3 #include 4 using namespace std; 5 int n,M,num[3000....
分类:
其他好文 时间:
2014-10-15 00:10:09
阅读次数:
280
Problem Description
A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first...
分类:
其他好文 时间:
2014-10-14 23:41:13
阅读次数:
266