hdu6063RXD and math(快速幂找规律)
来源:互联网 发布:win10网络时间同步 编辑:程序博客网 时间:2024/06/07 22:47
RXD and math
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 856 Accepted Submission(s): 468
Problem Description
RXD is a good mathematician.
One day he wants to calculate:
∑i=1nkμ2(i)×⌊nki−−−√⌋
output the answer module109+7 .
1≤n,k≤1018
μ(n)=1(n=1)
μ(n)=(−1)k(n=p1p2…pk)
μ(n)=0(otherwise)
p1,p2,p3…pk are different prime numbers
One day he wants to calculate:
output the answer module
Input
There are several test cases, please keep reading until EOF.
There are exact 10000 cases.
For each test case, there are 2 numbersn,k .
There are exact 10000 cases.
For each test case, there are 2 numbers
Output
For each test case, output "Case #x: y", which means the test case number and the answer.
Sample Input
10 10
Sample Output
Case #1: 999999937求满足式子的和(注意向下取整),由于n,k都是10^18,很大,所以找规律,打表打出的(1,1) ,(1,2),(1,3),(1,4)(2,1)(2,2)。。。(10,1),(10,2),(10,3),(10,4)的所有值找出规律,就是求n^k快速幂#include <cstdio>#include <cstring>#include <algorithm>#include <vector>#include <queue>#include <iostream>#define mod 1000000007using namespace std;#define ll long longlong long pow3(long long a,long long b){ long long ans = 1,base=a%mod;///这里注意取模 while(b) { if(b&1) ans = (ans*base)%mod; base= (base*base)%mod; b>>=1; } return ans;}int main(){ long long n,k; int ca=1; while(scanf("%lld %lld",&n,&k)!=EOF) { long long ans=pow3(n,k); printf("Case #%d: %lld\n",ca++,ans); } return 0;}
阅读全文
0 0
- hdu6063RXD and math(快速幂找规律)
- HDU6063RXD and math
- HDU6063RXD and math
- 2017杭电多校联赛第三场-RXD and math (hdu6063) 找规律快速幂
- HDU 6063 RXD and math 打表找规律 快速幂
- HDU 6063 RXD and math【快速幂】【打表找规律】
- hdu6198(矩阵快速幂+找规律)
- HDU 4990 Reading comprehension(找规律+矩阵快速幂)
- HDOJ 题目4602 Partition(找规律,快速幂)
- hdu 3519 快速幂矩阵(7)+找规律
- Key Set(找规律+组合数学+快速幂)
- HDU 1097 A hard puzzle(找规律,快速幂)
- HDU 4990 (找规律 矩阵快速幂)
- Poj 3070 矩阵快速幂(找规律法)
- HDU 4990 Reading comprehension(找规律+矩阵快速幂)
- hdu6198 number number number(找规律+矩阵快速幂)
- 【NOIP2006普及】数列 快速幂+找规律
- hdu 4506(快速幂+找规律)
- 1101. Quick Sort (25)快排
- A
- 机器学习第三周(三)--正则化
- 大数据 (九)Hadoop-使用eclipe插件操作HDFS
- UVA12338Anti-Rhyme Pairs(哈希+二分最长前缀)
- hdu6063RXD and math(快速幂找规律)
- python random和numpy random
- 微信支付接口升级,微信支付免充值代金券开通
- C++学习之容器<vector>
- 南阳oj 题目57 6174问题
- Linux server 中手动配网命令
- hdu 6058
- 二、java运行环境按照之-linux centos下安装jdk步骤【rpm安装方式】
- [随心译]2017.8.2-苹果的ARKit实景DEMO看起来简直不可思议