hdu6063-RXD and math
来源:互联网 发布:c语言数据类型举例 编辑:程序博客网 时间:2024/05/18 01:51
唉,我等弱鸡只能水一水水题了,这第三场这么多数学公式,真是难为我这个公式恐惧症了,这道题就是打表找到规律,发现答案就是(n^k%mod),然后用到快速幂,然后注意一下,快速幂的时候可能会超过long long 导致溢出,那么久要先mod再乘了,时间复杂度:log(n).
#include <iostream>#include <stdio.h>#include <string.h>#include <algorithm>#include <queue>#include <vector>#include <math.h>#define LL long longusing namespace std;const int maxn = 1e5+5;const LL mod=1e9+7;LL quck_mod(LL x,LL y){ LL ret=1; //x=x%mod; while(y>0){ if(y&1) ret=((ret%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; y>>=1; } return ret;}int main(){ LL n,k; int cas=1; while(scanf("%lld%lld",&n,&k)!=EOF) { LL ans=quck_mod(n,k); printf("Case #%d: %lld\n",cas++,ans%mod); } return 0;}
阅读全文
0 0
- HDU6063-RXD and math
- hdu6063-RXD and math
- HDU6063-RXD and math
- [hdu6063]RXD and math
- hdu6063 RXD and math
- HDU6063 RXD and math 快速幂
- HDU6063---RXD and math(2017多校联赛题目(???))
- Hdu6063 RXD and math(2017多校第3场)
- hdu6063 RXD and math(数学/打表)
- HDU6063 2017杭电多校联赛第三场-RXD and math
- 2017多校训练Contest3: 1008 RXD and math hdu6063
- HDU6063 [2017多校联合3] RXD and math 打表 快速幂
- 2017多校联合三/hdu6063 ( RXD and math )快速幂+思维
- 2017杭电多校联赛第三场-RXD and math (hdu6063) 找规律快速幂
- RXD and math HDU
- RXD and math
- RXD and math
- RXD and math
- cocos2d-x 的环境搭建
- hibernate和mybatis一对一和一对多配置
- jmeter---正则表达式
- day06
- 压缩算法——JPEG2000 编解码原理
- hdu6063-RXD and math
- 生成指定范围内的随机数
- R语言学习-交集和并集
- node环境中knockoutjs组件引入外部文件
- [Git]: 使用经验总结
- Maven项目jar包手动下载
- 数据结构基础 复原二叉树
- 家庭媒体中心解决方案(四、群晖系列nas基本功能使用指南篇2)
- ARKit 初体验