![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
快速幂
h1021456873
这个作者很懒,什么都没留下…
展开
-
HDU Rightmost Digit (快速幂)
Problem Description Given a positive integer N, you should output the most right digit of N^N. Input The input contains several test cases. The first line of the input is a single integer T原创 2015-07-30 16:10:44 · 384 阅读 · 0 评论 -
HDU 4602 Partition 组成n的方案中k有几个 (好题!!!!找规律题+快速幂)
Define f(n) as the number of ways to perform n in format of the sum of some positive integers. For instance, when n=4, we have 4=1+1+1+1 4=1+1+2 4=1+2+1 4=2+1+1 4=1+3 4=2+2 4=3+1原创 2016-01-29 13:09:44 · 590 阅读 · 0 评论 -
51nod 巨大的斐波那契数列(矩阵快速幂),递推式优化的好模板!!!!!!!
斐波那契数列的定义如下: F(0) = 0 F(1) = 1 F(n) = F(n - 1) + F(n - 2) (n >= 2) (1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, ...) 给出n,求F(n),由于结果很大,输出F(n) % 1000000009的结果即可。 Input原创 2015-10-24 16:12:20 · 1787 阅读 · 1 评论 -
51nod 1046 A^B Mod C (快速幂)
给出3个正整数A B C,求A^B Mod C。 例如,3 5 8,3^5 Mod 8 = 3。 Input 3个正整数A B C,中间用空格分隔。(1 Output 输出计算结果 Input示例 3 5 8 Output示例 3 #include #include #include using namespace std; typ原创 2015-10-12 16:18:18 · 967 阅读 · 0 评论 -
POJ 3641 Pseudoprime numbers (伪素数_快速幂)
Description Fermat's theorem states that for any prime number p and for any integer a > 1, ap = a (mod p). That is, if we raise a to the pth power and divide by p, the remainder is a. Some (but n原创 2015-09-21 20:31:37 · 466 阅读 · 1 评论 -
UVA 10006 Carmichael Numbers (暴力+快速幂取模)
#include #include using namespace std; typedef long long ll; int prime[70000]; void is_prime() { for(int i=2;i<=70000;i++) { if(!prime[i]) { for(int j=2*i;j<=70000;j+=i) prime[j]=1; } } }原创 2015-09-21 15:16:37 · 438 阅读 · 1 评论 -
51nod 1013 3的幂的和(等比数列求和_快速幂+逆元)
求:3^0 + 3^1 +...+ 3^(N) mod 1000000007 Input 输入一个数N(0 Output 输出:计算结果 Input示例 3 Output示例 40 关于逆元的一些知识点: 若对于数字A,C 存在X,使A * X = 1 (mod C) ,那么称X为 A 对C的乘法逆元。 逆元的原创 2015-10-25 10:02:42 · 2150 阅读 · 0 评论 -
cf B. Kolya and Tanya (快速幂_注意取模)
Kolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting in the vertexes of an equilateral triangle. More formally, there are 3n gn原创 2015-10-07 13:07:55 · 593 阅读 · 0 评论 -
HDU 1575 Tr A (矩阵快速幂)
Problem Description A为一个方阵,则Tr A表示A的迹(就是主对角线上各项的和),现要求Tr(A^k)%9973。 Input 数据的第一行是一个T,表示有T组数据。 每组数据的第一行有n(2 Output 对应每组数据,输出Tr(A^k)%9973。 Sample Input 2 2 2 1 0 0 1 3 9999999原创 2015-08-05 14:30:44 · 402 阅读 · 0 评论 -
HDU 本原串 (快速幂)
Problem Description 由0和1组成的串中,不能表示为由几个相同的较小的串连接成的串,称为本原串,有多少个长为n(n 答案mod2008. 例如,100100不是本原串,因为他是由两个100组成,而1101是本原串。 Input 输入包括多个数据,每个数据一行,包括一个整数n,代表串的长度。 Output 对于每个测试数据,输出一行,代表有多少原创 2015-07-30 16:07:04 · 416 阅读 · 0 评论 -
Codeforces 450B f【n】=f【n-1】-f【n-2】(矩阵快速幂,裸题)
Jzzhu has invented a kind of sequences, they meet the following property: You are given x and y, please calculate fn modulo 1000000007 (109 + 7). Input The first line contains two inte原创 2017-03-07 23:45:25 · 768 阅读 · 0 评论