51NOD 2026:Gcd and Lcm——题解】的更多相关文章

题目传送门 分析: 开始玩一个小小的trick 我们发现\(f(n)=\sum_{d|n}\mu(d)\cdot d\)是一个积性函数 所以: \(~~~~f(n)=\prod f(p_i^{a_i})\) \(~~~~f(gcd(x,y))\cdot f(lcm(x,y))=\prod f(p_i^{min(a_i,b_i)})\cdot f(p_i^{max(a_i,b_i)})\) 可以疯狂使用交换律然后... \(~~~~\prod f(p_i^{min(a_i,b_i)})\cdot…
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=2026 参考及推导:https://www.cnblogs.com/ivorysi/p/9157781.html (其公式有一处小问题,请注意.) 然后就没了……我觉得讲得挺详细了. 另外map跑得可能比哈希表还快可还行. #include<map> #include<cmath> #include<stack> #include<queu…
题解 话说LOJ说我今天宜学数论= =看到小迪学了杜教筛去蹭了一波小迪做的题 标解的杜教筛的函数不懂啊,怎么推的毫无思路= = 所以写了个复杂度稍微高一点的?? 首先,我们发现f是个积性函数,那么我们就有-- \(\prod_{i = 1}^{k}f(p_{i}^{a_{i}})\) 我们发现,对于每个质因子,gcd是取较小值,lcm取较大值 \(f(lcm(x,y)) * f(gcd(x,y)) = \prod_{i = 1}^{k} f(p_{i}^{max(a_{i},b_{i}) + m…
题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1575 万年巨坑终于填掉了…… 首先是煞笔西瓜的做题历程O_O. 原题要求$\sum_{i=1}^n\sum_{j=1}^i\sum_{k=1}^i [(i,j),(i,k)]$ 那么先推一波式子吧 balabala 我也忘记自己是怎么推的了(雾 总之最后推出来是这样的 $ ans=\sum_{i=1}^{n} f(\left\lfloor\frac{n}{i}…
GCD and LCM Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4497 Description Given two positive integers G and L, could you tell me how many solutions of (x, y, z) there are, satisfying that gcd(x, y, z) = G and…
GCD and LCM Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 2982    Accepted Submission(s): 1305 Problem Description Given two positive integers G and L, could you tell me how many solutions of…
Given two positive integers G and L, could you tell me how many solutions of (x, y, z) there are, satisfying that gcd(x, y, z) = G and lcm(x, y, z) = L? Note, gcd(x, y, z) means the greatest common divisor of x, y and z, while lcm(x, y, z) means the…
GCD and LCM Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 2977    Accepted Submission(s): 1302 Problem Description Given two positive integers G and L, could you tell me how many solutions of…
组合数学 GCD and LCM Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 451    Accepted Submission(s): 216 Problem Description Given two positive integers G and L, could you tell me how many solutions…
题目链接: https://cn.vjudge.net/problem/23709/origin 本题其实有坑 数据大小太大, 2的32次方,故而一定是取巧的算法,暴力不可能过的 思路是最大公因数的倍数是最小公倍数,又有a <= b所以可以知道 a = gcd, b = lcm AC代码如下: #include <cstdio> #define ll long long using namespace std; int main() { int T; scanf("%d&quo…