上一页 1 2 3 4 5 6 7 8 9 10 ··· 18 下一页
题目链接 题意: 给出这个式子的x和y,求fn 思路:很明显的矩阵快速幂,[fi,fi-1][{1,1}{-1,0}]=[fi+1,fi] #include <bits/stdc++.h> using namespace std; #define ll long long const int max Read More
posted @ 2020-09-28 19:26 Ldler Views(107) Comments(0) Diggs(0) Edit
题目链接 题意:n个模式串,一个待匹配串,求求每个模式串在待匹配串中出现次数。 思路:记录模式串尾端,然后遍历统计。 #include <bits/stdc++.h> using namespace std; const int N = 50*1010; int n; char a[1010][60 Read More
posted @ 2020-09-24 20:35 Ldler Views(104) Comments(0) Diggs(0) Edit
题目链接 题意:给n个模式串,m个待匹配串,每个串中包含哪些模式串打印出来。 思路:主要没有看清不止小写字母导致一直wa。用一个数组记录最后结尾的状态,然后去判断一下就好了。 #include <bits/stdc++.h> using namespace std; const int N = 1e Read More
posted @ 2020-09-24 20:15 Ldler Views(93) Comments(0) Diggs(0) Edit
题目链接 题意:给你一个长度为n的单词表,一个文本串,问你这个文本串中出现了单词表中多少个单词; 思路:老模板题了,记录一下结尾字母累加就好了。 #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 6; int n; n Read More
posted @ 2020-09-23 20:42 Ldler Views(94) Comments(0) Diggs(0) Edit
题目链接 题意:求和 n<=100000 思路:很明显可以发现对于ans[n]=ans[n-1]+Σi<nlcm(i,n)。所以现在要解决的是Σi<nlcm(i,n)。 下面图片的思路很详细: 所以可以通过线性的方式先求出Σi<nlcm(i,n)。 #include <bits/stdc++.h> Read More
posted @ 2020-09-23 20:35 Ldler Views(229) Comments(0) Diggs(0) Edit
题目链接 题意:给你n和m,令x为前m个素数,一共使用n个的乘积,例如n=3,m=2,则x=2*2*3或x=2*3*3,求所有Φ(x)的和。 思路:用到了欧拉函数的性质,首先对于x为素数,Φ(x)=x-1,然后若n*m=x,则Φ(n)*Φ(n)=Φ(x)。所以我们可以求出前500个素数,然后对其进行 Read More
posted @ 2020-09-22 21:00 Ldler Views(157) Comments(0) Diggs(0) Edit
题目链接 题意:求lcm(1,2,3,...,n),n<=1e8; 思路:很容易想到其答案为n之前的所有质因子的最大次幂的乘积。例如n=20,答案就是19*17*13*11*7*5*3^2*2^4。又容易发现可以通过根号n求出前面的最高次幂-1。然后打表前面的素数乘积即可求出答案。 但这题的时间和内 Read More
posted @ 2020-09-22 11:03 Ldler Views(150) Comments(0) Diggs(0) Edit
题目链接 题意:给你一个数n(n<=10^14),然后问n能用几个连续的数表示; 思路:设是以x开始的一段数的和为n,且有y个数,n=(x+x+y-1)*y/2。化简为n/y-(y-1)/2=x。因为x为整数,所以(y-1)/2和n/y都为整数。所以y-1为偶数,y为奇数。所以方案的种数就是n的奇数 Read More
posted @ 2020-09-18 16:54 Ldler Views(147) Comments(0) Diggs(0) Edit
题目链接 题意:求C(n,r)*p^q最后答案中末尾0的个数。 思路:很明显的思路是分解质因子2和5,可是C(n,r)如何分解呢。可以通过C(n,r)=n!/(n-r)!*r!。只要求出阶乘的因子个数就能得出答案。如何求出阶乘的因子个数,可以想到对于n!求p的质因子个数,在1~n中至少包含一个p的有 Read More
posted @ 2020-09-18 16:23 Ldler Views(139) Comments(0) Diggs(0) Edit
题目链接 题意:给你a,b和L,求一个最小的c满足lcm(a,b,c)=L。 思路:这题很容易被误导,求出a,b的最小公倍数为m,此时相当于求lcm(m,c)=L,容易被误导以为c=L/m。实际上L/m并一定不满足lcm(m,L/m)=L。 例如lcm(12,2)!=24。因为当满足lcm(m,L/ Read More
posted @ 2020-09-18 16:14 Ldler Views(116) Comments(0) Diggs(0) Edit
上一页 1 2 3 4 5 6 7 8 9 10 ··· 18 下一页