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…
题解 话说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: 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…
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…
题目链接: 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…
并不重要的前言 最近学习了一些数论知识,但是自己都不懂自己到底学了些什么qwq,在这里把知识一并总结起来. 也不是很难的gcd和lcm 显而易见的结论: 为什么呢? 根据唯一分解定理: a和b都可被分解为素因子的乘积,形如: 则显而易见的有一下结论: 相乘,得: 得证 几种求gcd的算法 欧几里得算法(辗转相除法) 辗转相减法(优化:stein_gcd) 欧几里得算法 基于事实: 实现: int gcd(int a, int b){ ) ? a : gcd( b , a % b) ; } 简短而…
GCD & LCM Inverse Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9928   Accepted: 1843 Description Given two positive integers a and b, we can easily calculate the greatest common divisor (GCD) and the least common multiple (LCM) of a a…
GCD and LCM Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 40    Accepted Submission(s): 22 Problem Description Given two positive integers G and L, could you tell me how many solutions of (x,…
GCD and LCM Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 78 Accepted Submission(s): 43 Problem Description Given two positive integers G and L, could you tell me how many solutions of (x, y, z)…