![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
快速幂
文章平均质量分 59
h1021456873
这个作者很懒,什么都没留下…
展开
-
HDU Rightmost Digit (快速幂)
Problem DescriptionGiven a positive integer N, you should output the most right digit of N^N.InputThe input contains several test cases. The first line of the input is a single integer T原创 2015-07-30 16:10:44 · 391 阅读 · 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 · 601 阅读 · 0 评论 -
51nod 巨大的斐波那契数列(矩阵快速幂),递推式优化的好模板!!!!!!!
斐波那契数列的定义如下:F(0) = 0F(1) = 1F(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 · 1798 阅读 · 1 评论 -
51nod 1046 A^B Mod C (快速幂)
给出3个正整数A B C,求A^B Mod C。例如,3 5 8,3^5 Mod 8 = 3。Input3个正整数A B C,中间用空格分隔。(1 Output输出计算结果Input示例3 5 8Output示例3#include#include#includeusing namespace std;typ原创 2015-10-12 16:18:18 · 975 阅读 · 0 评论 -
POJ 3641 Pseudoprime numbers (伪素数_快速幂)
DescriptionFermat'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 · 477 阅读 · 1 评论 -
UVA 10006 Carmichael Numbers (暴力+快速幂取模)
#include#includeusing 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 · 444 阅读 · 1 评论 -
51nod 1013 3的幂的和(等比数列求和_快速幂+逆元)
求:3^0 + 3^1 +...+ 3^(N) mod 1000000007Input输入一个数N(0 Output输出:计算结果Input示例3Output示例40关于逆元的一些知识点:若对于数字A,C 存在X,使A * X = 1 (mod C) ,那么称X为 A 对C的乘法逆元。逆元的原创 2015-10-25 10:02:42 · 2179 阅读 · 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 · 598 阅读 · 0 评论 -
HDU 1575 Tr A (矩阵快速幂)
Problem DescriptionA为一个方阵,则Tr A表示A的迹(就是主对角线上各项的和),现要求Tr(A^k)%9973。Input数据的第一行是一个T,表示有T组数据。每组数据的第一行有n(2 Output对应每组数据,输出Tr(A^k)%9973。Sample Input22 21 00 13 9999999原创 2015-08-05 14:30:44 · 414 阅读 · 0 评论 -
HDU 本原串 (快速幂)
Problem Description由0和1组成的串中,不能表示为由几个相同的较小的串连接成的串,称为本原串,有多少个长为n(n答案mod2008.例如,100100不是本原串,因为他是由两个100组成,而1101是本原串。Input输入包括多个数据,每个数据一行,包括一个整数n,代表串的长度。Output对于每个测试数据,输出一行,代表有多少原创 2015-07-30 16:07:04 · 424 阅读 · 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 modulo1000000007 (109 + 7).InputThe first line contains two inte原创 2017-03-07 23:45:25 · 776 阅读 · 0 评论