上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 18 下一页
题目链接 题意:给你一个B,已知A-A/10=B。让你求A。 思路:两边同时乘以10,得到10*A-A+x=10*B,所以A=(10*B-x)/9。而x的范围为0~9,所以枚举即可。 #include<stdio.h> #include<math.h> #include<string.h> #inc Read More
posted @ 2020-09-18 14:59 Ldler Views(104) Comments(0) Diggs(0) Edit
题目链接 题意:求n大于2的因子个数。n<=1e12 思路:先打表1e6的因子个数吗,然后对n进行素因子分解,然后用唯一分解定理求出答案。因为没有很快想到故记录。 #include<stdio.h> #include<math.h> #include<string.h> #include<map> Read More
posted @ 2020-09-16 21:23 Ldler Views(141) Comments(0) Diggs(0) Edit
题目链接 题意:给定一个区间[m, n],假设 小于m的与m互质的数的个数为 s(m),小于m+1的与m+1互质的数的个数为 s(m+1),……,小于n的与n互质的数的个数为 s(n)。如果 m == n,输出 a = s(m)*s(m),否则,输出 a = s(m)*s(m) + s(m+1)*s Read More
posted @ 2020-09-16 20:40 Ldler Views(143) Comments(0) Diggs(0) Edit
题目链接 题意:输出最长的前缀, 前缀要满足在原串中至少匹配3次。 思路:很容易想到前缀E和后缀E可以用next数组求出,然后在判断中间的E是否存在,具体做法是:next[len]=i,在[2 * i ,len - i](因为不能重合)内找是否有next[j]=i,存在则i就为答案,但是不存在的话不 Read More
posted @ 2020-09-16 12:48 Ldler Views(113) Comments(0) Diggs(0) Edit
题目链接 题意:通过第一个字符与a的关系翻译字符串,输出最长回文串和首尾下标,不存在则输出No solution! 思路:马拉车算法记录修改串的最长半径和下标。然后反推原串的起点到终点。 #include<stdio.h> #include<math.h> #include<string.h> #i Read More
posted @ 2020-09-16 12:44 Ldler Views(101) Comments(0) Diggs(0) Edit
题目链接 题意:n个字符串,两两拼接能最多形成多少种,自己可以和自己拼接。 思路:设a,b两个串要拼接判断其是否为回文串分三种情况考虑: 第一种:alen < blen a是b的反串前缀,且b的剩余部分可以认为是后缀是回文串 第二种:alen > blen b的反串是a的前缀,且a的后缀是回文串 第 Read More
posted @ 2020-09-14 21:31 Ldler Views(105) Comments(0) Diggs(0) Edit
题目链接 题意:求一个数组的回文串且满足条件为三角形,从小到大然后到小。 思路:在马拉车算法寻找右边len数组时添加判断条件即可。 #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using name Read More
posted @ 2020-09-14 20:07 Ldler Views(107) Comments(0) Diggs(0) Edit
题目链接 题意:就是要找出所有循环节的位置 思路:利用next失配数组实现跳转。长度为len-next(len)的前缀显然是符合题意的。 #include<stdio.h> #include<string.h> #include<algorithm> #define ll long long usi Read More
posted @ 2020-09-14 10:29 Ldler Views(93) Comments(0) Diggs(0) Edit
题目链接 题意:给你一个字符串问切一刀的最大价值。会给出26个字母的价值,而如果你切出来的一个字符串是回文串,则价值为回文串所有字母的和,否则为0.求最大价值。值得注意的是,字母价值可能为负数。 思路:可以想到马拉车算法求出P数组,然后暴力枚举。先预处理出字母价值的前缀和然后再去暴力。暴力过程中还是 Read More
posted @ 2020-09-14 10:25 Ldler Views(111) Comments(0) Diggs(0) Edit
题目链接 题意:给s个字符串,m个关系,n个字符串,当两个字符串满足m关系之一且相邻则在n个字符串中可交换,求n的最小。 思路:因为对于如果不满足关系的两个字符串a,b,若a在b前面,则a永远在b前面。所以可以利用不能交换的字符串做一个图,对其的拓扑序则为最后答案,因为当前面不能交换的先出队,后面的 Read More
posted @ 2020-09-11 19:53 Ldler Views(119) Comments(0) Diggs(0) Edit
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 18 下一页