RXD and math
来源:互联网 发布:吉比特和电魂网络比较 编辑:程序博客网 时间:2024/06/05 17:44
RXD and math
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 953 Accepted Submission(s): 520
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,计算公式的值,其中u(i)为莫比乌斯函数。
思路:
暴力打表找规律,发现公式的结果恰好为n^k,直接用快速幂求结果。
下面贴上代码:
#include<cstdio>using namespace std;typedef long long LL;const int INF=0x3f3f3f3f;const int mod=1e9+7;LL quickpow(LL a,LL b) //快速幂{ if(b<0) return 0; LL ret=1; a%=mod; while(b) { if(b & 1) ret=(ret*a)%mod; b>>=1; a=(a*a)%mod; } return ret;}int main (){ LL n,k,cas=1; while(scanf("%lld%lld",&n,&k)!=EOF) { LL ans=quickpow(n,k); printf("Case #%lld: %lld\n",cas++,ans); } return 0;}
阅读全文
0 0
- RXD and math HDU
- RXD and math
- HDU6063-RXD and math
- hdu6063-RXD and math
- RXD and math
- RXD and math
- HDU6063-RXD and math
- RXD and math
- [hdu6063]RXD and math
- hdu6063 RXD and math
- HDU 6063-RXD and math
- hdu-6063-RXD and math
- HDU 6063 RXD and math
- HDU 6063 RXD and math
- hdu--6063 RXD and math
- HDU 6063 RXD and math
- HDU-6063-RXD and math-
- HDU--6063--RXD and math
- rvds2.2\rvds4.0按照网上的按照破解方法多次安装破解失败的一种解决方法
- mysql,命令导入\导出表结构或数据
- NestedScrollView嵌套RecyclerView滑动冲突
- C++实现动态顺序表
- 允许Sierra系统打开任意来源软件
- RXD and math
- 堆排序
- 说一下我对Mvvm模式的理解
- Android初级教程
- C++设计模式-Prototype原型模式
- Java虚拟机插曲之参数详解
- python实现随机漫步
- EventBus3.0简单使用
- 欢迎使用CSDN-markdown编辑器