题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2685 题意:求gcd(a^m - 1, a^n - 1) mod k 思路:gcd(a^m - 1, a^n - 1) = a^gcd(m, n) - 1 code: #include <stdio.h> int gcd(int a, int b) { return !b ? a : gcd(b, a%b); } int mod_pow(int a, int x, int mod) { int t…
题目链接 根据公式 \[ gcd(a^m-1, a^n-1) = a^{gcd(m, n)}-1 \] 就可以很容易的做出来了. #include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #include <complex> #include <cmath> #include <map…
求$(a^n-1,a^m-1) \mod k$,自己手推,或者直接引用结论$(a^n-1,a^m-1) \equiv a^{(n,m)}-1 \mod k$ /** @Date : 2017-09-21 21:41:26 * @FileName: HDU 2685 结论 定理 推导.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/ * @Version…
I won't tell you this is about number theory Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 458    Accepted Submission(s): 142 Problem Description To think of a beautiful problem description is…
麻痹,感冒了. ------------------------------------------------感冒了的分割线------------------------------------------------ HDU 1210 也就是 FOJ 1062 http://acm.hdu.edu.cn/showproblem.php?pid=1210 http://acm.fzu.edu.cn/problem.php?pid=1062 Eddy是个ACMer,他不仅喜欢做ACM题,而且对…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=6322 Problem Description In number theory, Euler's totient function φ(n) counts the positive integers up to a given integer n that are relatively prime to n . It can be defined more formally as the number…
Lost's revenge Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 2262    Accepted Submission(s): 565 Problem Description Lost and AekdyCoin are friends. They always play "number game"(A bori…
Count the string Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 8845    Accepted Submission(s): 4104 Problem Description It is well known that AekdyCoin is good at string problems as well as n…
LCM Walk Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5584 Description A frog has just learned some number theory, and can't wait to show his ability to his girlfriend. Now the frog is sitting on a grid map o…
abs 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5778 Description Given a number x, ask positive integer y≥2, that satisfy the following conditions: The absolute value of y - x is minimal To prime factors decomposition of Y, every element factor a…