题目链接 根据公式 \[ 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…
题目链接: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…
求$(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…
HDU 1005 Number Sequence(数论) Problem Description: A number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. Given A, B, and n, you are to calculate the value of f(n).   Input The input consists of multipl…
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题,而且对…
Missing number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) [Problem Description] There is a permutation without two numbers in it, and now you know what numbers the permutation has. Please find the two numbers…
传送门 参考资料: [1]:https://www.2cto.com/kf/201308/233613.html 题意,题解在上述参考资料中已经介绍的非常详细了,接下来的内容只是记录一下我的理解: 我的学习记录: 定义 f(x) : x的因子个数: φ(x) : x之前与x互素的数的个数: 那么 F(x) = x - f(x) - φ(x) + 1; 为什么要 +1 呢? 因为 f(x) 和 φ(x) 同时包含 1 这个数,所以要加上多减去的 1: 根据算术基本定理: 任何一个大于1的自然数 N…
1. 利用数学公式lg(n!)=lg(2)+lg(3)+....+lg(n) 求解 2.…
链接: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…