HDU 6063 RXD and math
2017-08-02 10:16
393 查看
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
题意:
一看就懂不用多说了吧。
思路:
官方题解:
实际上答案大家都是知道的,我们来推一推为什么
既然x=a^2*b(b为无平方因子数),且μ(b)^2一定为1(仔细想想μ(i)的定义),令n^k=a^2*i,我们枚举的是i,由于a=
,且1到n^k的每个数可以唯一表示成a^2*i
的形式,每次枚举i,我们就可以得到a个可由a^2*i(x=1^2*i,x=2^2*i......x=a^2*i)组成的数,当枚举下一个i时,一定不会存在a^2*i与前面的x重复的情况,因此该公式计算的是1到n^k有多少个数。
注意:如果一开始n很大要对它取模。
示例程序
/* Problem : 6063 ( RXD and math ) Judge Status : Accepted RunId : 21449305 Language : G++ Code Len : 470 B Code Render Status : Rendered By HDOJ G++ Code Render Version 0.01 Beta */ #include <cstdio> #define LDQ 1000000007 using namespace std; long long quick(long long x,long long k) { long long t=x,ans=1; while(k!=0) { if(k%2==1) { ans=(ans*t)%LDQ; } t=(t*t)%LDQ; k=k/2; } return ans; } int main() { long long n,k; for(int i=1;scanf("%lld %lld",&n,&k)!=EOF;i++) { printf("Case #%d: %lld\n",i,quick(n%LDQ,k)); } return 0; }
相关文章推荐
- HDU 6063 RXD and math (打表)
- hdu-6063-RXD and math
- HDU--6063--RXD and math
- H - RXD and math HDU - 6063 多校第三场
- RXD and math HDU - 6063
- HDU 6063 RXD and math【数学】
- hdu 6063 RXD and math (规律题)
- HDU 6063 RXD and math(快速幂)
- HDU 6063 17多校3 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
- 17暑假多校联赛3.8 HDU 6063 RXD and math
- HDU 6063 RXD and math【快速幂】【打表找规律】
- HDU 6063 RXD and math 打表找规律 快速幂
- (2017多校训练第三场)HDU - 6063 RXD and math 找规律 + 快速幂
- 2017 多校训练第三场 HDU 6063 RXD and math
- HDU 6063 RXD and math(数论)