hdu 2817 快速幂入门
来源:互联网 发布:淘宝退货卖家给假地址 编辑:程序博客网 时间:2024/05/22 02:21
点击打开链接
#include <iostream>#include <algorithm>#include <cstdio>#include <vector>#include <cstring>#include <queue> using namespace std;const int M = 10010;const int Mod=200907;typedef long long LL;LL pow(LL x,LL n) //二分快速幂 {if(n==0)return 1;if(n%2) // a^n %c = a^n-1*a %c {return pow(x,n-1)*x%Mod;}else // a^n %c = (a^n/2 * a^n/2) %c{LL a=pow(x,n/2); return a*a%Mod;}}int main(){int t;cin>>t;while(t--){LL a,b,c,k;cin>>a>>b>>c>>k;if(b-a==c-b){LL d=c-b;LL ans;ans=(a%Mod+((k-1)*d)%Mod)%Mod;cout<<ans<<endl;}else {LL q=b/a;LL ans=c;// (a*b) (a%c * b%c) 同余c cout<<(c%Mod*pow(q,k-3)%Mod)%Mod<<endl;//快速幂取模 }}return 0;}
0 0
- hdu 2817 快速幂入门
- hdu 2035 人见人爱A^B(快速幂入门)
- hdu 1097 A hard puzzle(快速幂入门)
- hdu 1061 Rightmost Digit(快速幂入门)
- hdu 1420 Prepared for New Acmer(快速幂入门)
- hdu 1575 Tr A(矩阵快速幂入门)
- HDU 1575 Tr A (矩阵快速幂入门)
- HDU 1575 Tr A(矩阵快速幂 水 入门)
- HDU 1061 Rightmost Digit(快速幂入门)
- HDU: 1575 Tr A(矩阵快速幂入门)
- hdu-1575-Tr A(矩阵快速幂入门题)
- hdu 1575 Tr A(矩阵快速幂 入门)
- Codevs_P3500 快速幂入门
- [codevs3500] 快速幂入门
- 快速幂入门
- 快速幂学习入门
- 矩阵快速幂入门
- sdnu1349.快速幂入门
- arm常见的总线类型
- Ural Championship 2013 H E-Lite
- Leetcode解题笔记(Linked List)
- 如何在CSDN博客中的所贴的代码进行【代码块】显示
- TVDI中线性拟合干湿边的步骤
- hdu 2817 快速幂入门
- LeetCode:Valid Sudoku与Sudoku Solver
- 垃圾收集器与内存分配策略
- HTTPS双向认证原理
- 【大型网站技术实践】初级篇:借助Nginx搭建反向代理服务器
- 【数据库】数据库发展阶段
- 【经典算法】:链表翻转
- 插件式开发(四)---关于资源问题
- linux文件的权限属性与操作