题目链接: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 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). InputThe input consists of multiple test cases. Each test case contains 3 integers A,…