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

打表大法好啊!打表之后发现就是求n^k%MOD

记得对n先做预处理取模,否则快速幂也救不了啊

 #include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
const long long MOD=1e9+; long long quickmod(long long a,long long b,long long m)
{
long long ans = ;
while(b)//用一个循环从右到左遍历b的所有二进制位
{
if(b&)//判断此时b[i]的二进制位是否为1
{
ans = (ans*a)%m;//乘到结果上,这里a是a^(2^i)%m
b--;//把该为变0
}
b/=;
a = a*a%m;
}
return ans;
} int main()
{
long long n,k;
int t=;
while(~scanf("%lld%lld",&n,&k))
{
printf("Case #%d: ",t++);
n%=MOD;
printf("%lld\n",quickmod(n,k,MOD));
}
return ;
}

打表程序如下:

 #include<cstdio>
#include<iostream>
#include<cmath>
using namespace std; #define MOD 1000000000+7 bool panduan (long long num)
{
long long i;
for(i=;i<=sqrt((double)num)+;i++)
{
if(num%(i*i)==)
return true;
}
return false;
} int main()
{
int n,k;
long long num;
long long res=;
for(int n=;n<=;n++)
for(int k=;k<=;k++)
{
res=;
num=pow((double)n,(double)k);
for(int i=;i<=num;i++)
{
if(!panduan(i))
res+=(long long)(sqrt((double)(num/i)));
res%=MOD;
}
printf("%d %d %lld\n",n,k,res);
}
return ;
}

每一行三个数字分别表示n,k,res

HDU 6063 17多校3 RXD and math(暴力打表题)的更多相关文章

  1. HDU 6066 17多校3 RXD's date(超水题)

    Problem Description As we all know that RXD is a life winner, therefore he always goes out, dating w ...

  2. HDU 6060 17多校3 RXD and dividing(树+dfs)

    Problem Description RXD has a tree T, with the size of n. Each edge has a cost.Define f(S) as the th ...

  3. HDU 6090 17多校5 Rikka with Graph(思维简单题)

    Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he ...

  4. HDU 6095 17多校5 Rikka with Competition(思维简单题)

    Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he ...

  5. HDU 6140 17多校8 Hybrid Crystals(思维题)

    题目传送: Hybrid Crystals Problem Description > Kyber crystals, also called the living crystal or sim ...

  6. HDU 6143 17多校8 Killer Names(组合数学)

    题目传送:Killer Names Problem Description > Galen Marek, codenamed Starkiller, was a male Human appre ...

  7. HDU 6045 17多校2 Is Derek lying?

    题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=6045 Time Limit: 3000/1000 MS (Java/Others)    Memory ...

  8. HDU 6124 17多校7 Euler theorem(简单思维题)

    Problem Description HazelFan is given two positive integers a,b, and he wants to calculate amodb. Bu ...

  9. HDU 3130 17多校7 Kolakoski(思维简单)

    Problem Description This is Kolakosiki sequence: 1,2,2,1,1,2,1,2,2,1,2,2,1,1,2,1,1,2,2,1……. This seq ...

随机推荐

  1. javascript作用域、闭包、对象与原型链

    原文作者总结得特别好,自己收藏一下.^-^ 1.作用域1.1函数作用域JS的在函数中定义的局部变量只对这个函数内部可见,称之谓函数作用域.它没有块级作用域(因此if.for等语句中的花括号不是独立作用 ...

  2. Oracle11g温习-第十九章:审计(audit)

    2013年4月27日 星期六 10:52 1.审计的功能:监控用户在database 的 action (操作) 2.审计分类 1) session :在同一个session,相同的语句只产生一个审计 ...

  3. UI基础五:简单的OP组件POPUP搜索帮助

    需求:给一个配置表,需要根据配置表来弹出选择框,并将选择的数据添加到SALES ORDER的项目 BSP_WD_CMPWB 新建组件:ZHSI_JPMPG 新建视图,适用VALUE NODE 参考表Z ...

  4. xpath 获取表单的值

    <input type="hidden" id="hospital_id" value="6666sui"> $selector ...

  5. SSL证书读取

    证书内容: MIIDhDCCAmygAwIBAgIFAV0Imw0wDQYJKoZIhvcNAQELBQAwXDEnMCUGA1UEAwweczUwLTYyLTEzNS0xNS5zZWN1cmVzZX ...

  6. [转]perftools查看堆外内存并解决hbase内存溢出

    最近线上运行的hbase发现分配了16g内存,但是实际使用了22g,堆外内存达到6g.感觉非常诡异.堆外内存用一般的工具很难查看,可以通过google-perftools来跟踪: http://cod ...

  7. Java 实现倒计时(由秒计算天、小时、分钟、秒)

    public class Countdown4 { private static long day = 0; private static long hour = 0; private static ...

  8. Uva 10635 - Prince and Princess 问题转化,元素互不相同(在自身序列中独特)的两个数列的LCS,LIS 难度: 2

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  9. Leetcode 回溯法 典型例题

    那些要求列举所有的情况,或者说所有的情况都要探讨一下的例题,一般都可以考虑回溯法. 当遇到一个可以用到回溯法的时候需要按照如下步骤进行: 1.确定问题一个可以用到回溯法的时候需要按照如下步骤进行: 1 ...

  10. HTTP协议详细解析

    HTTP协议详解 HTTP协议(HyperText Transfer Protocol,超文本传输协议)是因特网上应用最为广泛的一种网络传输协议,所有的WWW文件都必须遵守这个标准. HTTP是一个基 ...