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. python-flask-配置文件的源码分析

    方式一:app.config['xx'] = 'xxx'源码分析:#第1步:class Flask(_PackageBoundObject):    self.config = self.make_c ...

  2. Maven管理jar包依赖常出现的不能实例化类的问题

    you'ji 在maven管理jar包依赖时,存在一种常见的问题. pom.xml文件配置没问题,通过eclipse里中的maven dependencies查看,也确实有这个jar 包,或者这个类. ...

  3. Nodejs--util模块

    util.inspect util.inspect是一个将任意对象转换 为字符串的方法,通常用于调试和错误输出. 它至少接受一个参数 object,即要转换的对象. util.inspect(obje ...

  4. 二、持久层框架(Hibernate)

    一.Hibernate对象的状态 实体类对象在Hibernate中有3中状态:瞬时,持久,脱管. 瞬时:没有和Hibernate发生任何关系,在数据库中也没有对应的记录,一旦JVM结束,对象就消失了 ...

  5. Windows系统目录解释

    目录 说明 C:\Program Files 64位程序安装目录 C:\Program Files (x86) 32位程序安装目录 C:\Windows 操作系统主要目录 C:\Windows\Sys ...

  6. 开发Web应用(2)(二十一)

    在完成配置之后,举一个简单的例子,在快速入门工程的基础上,举一个简单的示例来通过Thymeleaf渲染一个页面. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 ...

  7. python(5)之集合

    集合是一个无序的,不重复的数据组合,它的主要作用如下: 1.去重,把一个列表变为集合就自动去重了 2.关系测试,测试两组数据之间的交集.并集.差集等 常用操作如下: #集合的操作 list_1={1, ...

  8. javascript中的require、import和export模块文件

    CommonJS 方式 文件输出如math.js: math.add = function(a,b){ return a+b; }exports.math = math; 文件引入: math = r ...

  9. Win10系列:UWP界面布局基础6

    资源合并 前面提到过,可以将资源字典定义在单独的XAML文件中,这样的文件被称为资源字典文件.那么,在需要引用文件中的资源时可以通过ResourceDictionary元素的MergedDiction ...

  10. 基于WMI的信息查询和编辑,按微软的说明一般都是

    晕!这个不是很简单的东西吗? //---------WMI---------- type Rec_Wmi = record ComputerName: string; Namespace: strin ...