hdu 6063 RXD and math(快速幂)
RXD and math
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 568 Accepted Submission(s): 306
One day he wants to calculate:
output the answer module 109+7.
1≤n,k≤1018
p1,p2,p3…pk are different prime numbers
There are exact 10000 cases.
For each test case, there are 2 numbers n,k.
题解:n^k % mod
注意 :n因为非常大所以在开始就要先用 mod 运算一遍
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<vector>
using namespace std;
const long long m=1e9+;
long long n,k;
long long solve(long long a,long long b)
{
a=a%m;
long long ans=;
while(b)
{
if (b&)ans=(ans*a)%m;
b>>=;
a=(a*a)%m;
}
return ans;
}
int main()
{
int cas=;
while(scanf("%lld%lld",&n,&k)!=EOF)
{
printf("Case #%d: %lld\n",++cas,solve(n,k));
}
return ;
}
hdu 6063 RXD and math(快速幂)的更多相关文章
- HDU 6063 - RXD and math | 2017 Multi-University Training Contest 3
比赛时候面向过题队伍数目 打表- - 看了题解发现确实是这么回事,分析能力太差.. /* HDU 6063 - RXD and math [ 数学,规律 ] | 2017 Multi-Universi ...
- HDU - 6063 RXD and math
Bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6063 打表发现规律是n^k #include <iostream> #inc ...
- 2017 ACM暑期多校联合训练 - Team 3 1008 HDU 6063 RXD and math (莫比乌斯函数)
题目链接 Problem Description RXD is a good mathematician. One day he wants to calculate: ∑i=1nkμ2(i)×⌊nk ...
- 数学--数论--HDU 6063 RXD and math (跟莫比乌斯没有半毛钱关系的打表)
RXD is a good mathematician. One day he wants to calculate: output the answer module 109+7. p1,p2,p3 ...
- HDU.1575 Tr A ( 矩阵快速幂)
HDU.1575 Tr A ( 矩阵快速幂) 点我挑战题目 题意分析 直接求矩阵A^K的结果,然后计算正对角线,即左上到右下对角线的和,结果模9973后输出即可. 由于此题矩阵直接给出的,题目比较裸. ...
- hdu 3117 Fibonacci Numbers 矩阵快速幂+公式
斐波那契数列后四位可以用快速幂取模(模10000)算出.前四位要用公式推 HDU 3117 Fibonacci Numbers(矩阵快速幂+公式) f(n)=(((1+√5)/2)^n+((1-√5) ...
- hdu 2604 Queuing(矩阵快速幂乘法)
Problem Description Queues and Priority Queues are data structures which are known to most computer ...
- HDU 2842 (递推+矩阵快速幂)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2842 题目大意:棒子上套环.第i个环能拿下的条件是:第i-1个环在棒子上,前i-2个环不在棒子上.每个 ...
- HDU 4704 Sum (费马定理+快速幂)
Sum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Subm ...
随机推荐
- jstack用法
第一步先找出Java进程ID,我部署在服务器上的Java应用名称为mrf-center: root@ubuntu:/# ps -ef | grep mrf-center | grep -v grep ...
- 伪类 :after 清除浮动的原理和方法
浮动元素容器的clearing问题1. 问题的由来有这样一种情形:在一个容器(container)中,有两个浮动的子元素.<div> <div style=" ...
- JS正则表达式从入门到入土(9)—— test方法以及它的那些坑
test方法 test方法介绍 RegExp.prototype.test(str) test方法用于测试字符串参数中是否存在匹配正则表达式模式的字符串 test方法的使用 let reg = /\w ...
- Greatest Common Increasing Subsequence
/*HDU1423 最长公共递增*/ #include <stdio.h> #include <string.h> #include <iostream> usin ...
- Python3.x:打包为exe执行文件(window系统)
Python3.x:打包为exe执行文件(window系统) window系统下发布: 一.安装pyinstaller(PyInstaller 3.3.1) cmd安装命令: pip install ...
- RocEDU.阅读.写作《乌合之众》(二)
第二卷 群体的意见与信念 决定着群体意见与信念的因素分为两类:直接因素与间接因素. 直接因素:使观念采取一定形式并且使它能够产生一定结果的因素. 间接因素:能够使群体接受某些信念并使其难以接受别的信念 ...
- BootStrap实现图片轮播
<div class="container"> <div data-ride="carousel" id="carou ...
- Can't connect to any repository: xxxxxx Error writing request body to server
今天在git提交代码时一直报如下错误: Can't connect to any repository: https://gitee.com/xxxxxx(https://gitee.com/xxxx ...
- 【jdk源码分析】java多线程开启的三种方式
1.继承Thread类,新建一个当前类对象,并且运行其start()方法 package com.xiaostudy.thread; /** * @desc 第一种开启线程的方式 * @author ...
- 解题报告:codeforce 7C Line
codeforce 7C C. Line time limit per test1 second memory limit per test256 megabytes A line on the pl ...