HDU6063-RXD and math
来源:互联网 发布:网络主播怎么赚钱 编辑:程序博客网 时间:2024/06/04 21:06
RXD and math
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 448 Accepted Submission(s): 230
Problem Description
RXD is a good mathematician.
One day he wants to calculate:
∑i=1nkμ2(i)×⌊nki−−−√⌋
output the answer module 109+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
Input
There are several test cases, please keep reading until EOF.
There are exact 10000 cases.
For each test case, there are 2 numbers n,k.
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
Source
2017 Multi-University Training Contest - Team 3
题目大意:计算题中式子
解题思路:打表找到规律n^k
打表代码:
#include<iostream>#include<cstdio>#include<cmath>using namespace std;typedef long long LL;int mu[100005];int MAXN=1e5;void init(){ mu[1]=1; for(int i=1;i<=MAXN;i++) { for(int j=2*i;j<=MAXN;j+=i) { mu[j]-=mu[i]; } }}int main(){ init();// for(int i=1;i<=100;i++)// {// cout<<mu[i]<<" ";// } for(int i=1;i<=1000;i++) { int up=i; LL ans=0; for(int j=1;j<=up;j++) { ans+=(mu[j]*mu[j])*(int)(sqrt(i/j)); } cout<<i<<": "<<ans<<endl; }}
AC代码:
#include<iostream>#include<cstdio>#include<cmath>using namespace std;typedef long long LL;const LL MOD=1e9+7;LL quickpow(LL x,LL y){ LL res=1; while(y) { if(y&1) res=(res*x)%MOD; x=((x%MOD)*(x%MOD))%MOD; y>>=1; } return res;}int main(){ LL n,k; int cas=0; while(scanf("%lld%lld",&n,&k)!=EOF) { printf("Case #%d: %lld\n",++cas,quickpow(n,k)); }}
- 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
- Git-理论篇-版本库的交互
- Netty系列之Netty高性能之道
- ios reason: 'Invalid parameter not satisfying: url'((无效的URL))
- 欧拉计划
- GCD详解
- HDU6063-RXD and math
- linux(7)
- 等待多线程完成的CountDownLatch
- 独创共识机制POI:他们想改变原创内容的商业模式,帮助中小型的优质IP解决早期变现问题
- 空类
- js十大排序代码实现(二)
- Integer.parseInt()和Integer.valueOf()的区别
- Android初级开发(四)——补充2、spinner的简单使用
- 控制台游戏——五子棋