![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
快速幂
旺旺_碎_冰冰
这个作者很懒,什么都没留下…
展开
-
快速幂&快乘 HDU 5187
#include #include #include #include using namespace std; int main() { // string s; // while(cin>>s) // { // cout<<s<<endl; // for(int i=0;s[i]!='\0';i++) // printf("原创 2017-11-11 11:20:29 · 340 阅读 · 0 评论 -
51 nod 1013 3的幂的和(乘法逆元)
求:3^0 + 3^1 +...+ 3^(N) mod 1000000007 Input 输入一个数N(0 <= N <= 10^9) Output 输出:计算结果 Sample Input 3Sample Output 40直接暴力是会超时的,得用到等比数列前n项和公式sum=a1(1-q^n)/(1-q).但数据很大,题目要求取余一个mod,那么就要把除以(1-q)改成乘以(1-q...原创 2018-01-11 11:23:09 · 182 阅读 · 0 评论 -
51nod n^n的末位数字(快速幂||找循环节)
给出一个整数N,输出N^N(N的N次方)的十进制表示的末位数字。Input 一个数N(1 <= N <= 10^9) Output 输出N^N的末位数字 Sample Input 13Sample Output 3方法很多:快速幂可以,找循环节也可以。快速幂:#include<stdio.h> #include<string.h> #include<alg...原创 2018-01-11 12:58:27 · 254 阅读 · 0 评论