
数论
文章平均质量分 64
Neutralzz
这个作者很懒,什么都没留下…
展开
-
UVA 10892 LCM Cardinality (因子分解 水题)
题意:求有多少对(a,b) 使lcm(a,b) = n。 思路:对n因子分解,暴力枚举。 代码: #include #include using namespace std; typedef long long LL; LL n,top,a[10005]; LL gcd(LL a,LL b){ return b != 0 ? gcd(b,a%b) : a; } LL lcm(原创 2015-07-16 17:57:23 · 360 阅读 · 0 评论 -
CodeForces 55D Beautiful numbers (数位DP)
题意:一个数字,如果它能被所有的非零数字整除,就为 Beautiful numbers。 参考题解:点击打开链接 dp[位数][高位数字模2520的余数][最小公倍数] AC代码: #include #include #include #include using namespace std; typedef __int64 LL; LL c[2550],g[2550][10]原创 2015-07-22 15:27:53 · 350 阅读 · 0 评论 -
Hdu 5317 RGCDQ (dp+预处理)
解析:F(x)的最大值是7,直接通过dp统计各个值的前缀和即可。 [code]: #include #include #include #include #include using namespace std; const int maxn = 1e6+5; int dp[maxn][9]; int divide(int n){ int i,j,ans = 0; for原创 2016-07-10 20:06:29 · 247 阅读 · 0 评论 -
HDU 5288 OO’s Sequence (数论)
题意:定义一个函数f(l,r) = i的个数使得在区间[l,r]中不存在a[i]%a[j]=0。∑i=1..n∑j=i..n f(i,j) mod (10^9+7)。 解析:通过枚举因子,从前到后再从后到前求出能包含i的区间的左右端点的边界,即可。 [code]: #include #include #include using namespace std; typedef long l原创 2016-07-06 08:27:20 · 213 阅读 · 0 评论 -
HDU 5297 Y sequencew(容斥+收敛迭代)
题目:从1开始的无限长正整数序列(1,2,3,4,5,...),剖去所有可以写成a^b的数(2 解析:首先对于每一个r处理出对应容斥的数字,用vector记录下来以降低复杂度。 开始的时候同样像的是二分,超时……看了一篇题解后,考虑序列的性质,向前迭代时是不断收敛的。(具体看代码) [code]: #include #include #include #include #include #原创 2016-07-06 10:25:23 · 275 阅读 · 0 评论