首页
Python
Java
IOS
Andorid
NodeJS
JavaScript
HTML5
【
[BZOJ 2721] [Violet 5] 樱花 【线性筛】
】的更多相关文章
【BZOJ 2721】 2721: [Violet 5]樱花 (筛)
2721: [Violet 5]樱花 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 599 Solved: 354 Description Input Output Sample Input Sample Output HINT Source interviewstreet--EQUATIONS [分析] 之前推出来然后几天直接打然后把$n!^2$的约数记成$n^2$的约数也是醉.. 先通分. 则$(x+y)*n!=x*y$ 设$g=gcd(x,…
[BZOJ 2721] [Violet 5] 樱花 【线性筛】
题目链接:BZOJ - 2721 题目分析 题目大意:求出 1 / x + 1 / y = 1 / n! 的正整数解 (x, y) 的个数. 显然,要求出正整数解 (x, y) 的个数,只要求出使 y 为正整数的正整数 x 的个数,或者求出使 x 为正整数的正整数 y 的个数即可. 那么我们来转化一下这个式子: 通分: (x + y) / xy = 1 / n! n!(x + y) = xy 将 y 分离出来: n!x = xy - n!y n!x = (x - n!)y y = n!x / (…
【BZOJ2721】[Violet 5]樱花 线性筛素数
[BZOJ2721][Violet 5]樱花 Description Input Output Sample Input 2 Sample Output 3 HINT 题解:,所以就是求(n!)2的约数个数 又有一个结论,若n=Πpi^ei,那么n的约数个数就是Π(ei+1),所以我们只需要筛出1-n 的所有素数,再分别计算每个素数的贡献就行了. #include <cstdio> #include <cstring> #include <iostream> #defi…
bzoj 2721[Violet 5]樱花 数论
[Violet 5]樱花 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 671 Solved: 395[Submit][Status][Discuss] Description Input Output Sample Input Sample Output HINT 题解: 上面废话许多. 设n!=z,y=z+d 1/x+1/y=1/z 1/x+1/(z+d)=1/z (x+z+d)/(x*z+dx)=1/z z(x+z+d)=x*z+d…
BZOJ 2721: [Violet 5]樱花
(X-N)(Y-N)=N^2 #include<cstdio> using namespace std; const int mod=1e9+7; int n,cnt,isprime[1000005],prime[1000005]; void Pre_prime(){ for (int i=2; i<=n; i++){ if (!isprime[i]) prime[++cnt]=i; for (int j=1; j<=cnt && i*prime[j]<=n;…
【BZOJ-2721】樱花 线性筛 + 数学
2721: [Violet 5]樱花 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 499 Solved: 293[Submit][Status][Discuss] Description Input Output Sample Input 3 Sample Output 9 HINT Source interviewstreet--EQUATIONS Solution 巧妙! $\frac{1}{x}+\frac{1}{y}=\frac{1…
2721: [Violet 5]樱花
2721: [Violet 5]樱花 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 547 Solved: 322[Submit][Status][Discuss] Description Input Output Sample Input Sample Output HINT Source interviewstreet--EQUATIONS 分析: 考虑$y$大于$n!$,但是要求个数,所以不可能无限大,所以我们需要寻找的就是上界,考…
BZOJ 2693: jzptab [莫比乌斯反演 线性筛]
2693: jzptab Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 1194 Solved: 455[Submit][Status][Discuss] Description Input 一个正整数T表示数据组数 接下来T行 每行两个正整数 表示N.M Output T行 每行一个整数 表示第i组数据的结果 Sample Input 1 4 5 Sample Output 122 HINT T <= 10000 N, M<=1000000…
2721: [Violet 5]樱花|约数个数
先跪一发题目背景QAQ 显然x,y>n!,然后能够设y=n!+d 原式子能够化简成 x=n!2d+n! 那么解的个数也就是n!的因子个数,然后线性筛随便搞一搞 #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<queue> #include<vector> #include<set> #include<ma…
[bzoj 2190][SDOI2008]仪仗队(线性筛欧拉函数)
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=2190 分析:就是要线性筛出欧拉函数... 直接贴代码了: memset(ans,,sizeof(ans)); ans[]=; ;i<=n;++i) if(!ans[i]) for(int j=i;j<=n;j+=i) { if(!ans[j]) ans[j]=j; ans[j]=ans[j]/i*(i-); }…