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. 配置ssh免密登录

    安装ssh sudo apt-get install ssh 产生密钥:ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa (rsa为ssh的加密方式 ...

  2. 7. 反转整数(Reverse Integer) C++

    知识点: 内置变量 INT_MAX   INT_MIN 运算结果是否溢出的判断 判断pop>7即pop>INT_MAX%10 判断pop<-8即pop<INT_MIN%10 c ...

  3. Linux Shell获取系统资源使用百分比(CentOS)

    CPU使用率: top -b -n | | 内存使用率: free -m | grep '^-' | awk '{print $3/($3+$4)*100"%"}' IO使用率(F ...

  4. weblogic隐藏版本号教程(10.3.6为例)

    隐藏版本号,如同大多数中间件都是取消Server头的发送:weblogic而言其默认就是不发送Server头的(即下边的“发送服务器标头”默认就是没钩选的). 写此教程的原因,一是以防Server头被 ...

  5. vuex的学习例子

    最近在学习vuejs,一直有听说vuex,用来实现多组件共享的一种状态管理模式,但是网上都说,不要为了用vuex而用vuex,大概意思就是尽量少用vuex,一些小项目可以用bus来实现组件之间的传值问 ...

  6. AI工具(缩放工具)(路径查找器)(旋转工具)(镜像工具)5.12

    缩放工具:选择图形,点击工具栏缩放工具,”ENTER"输入缩放比例,“复制”完成缩放复制. 路径查找器:选择两个图形,“窗口”“路径查找器”“差集”:大圆减去小圆,留下圆环. “减去顶层”: ...

  7. laravel创建新的提交数据

    public function store() { $this->validate(request(),[ 'title'=>'required|string|max:100|min:10 ...

  8. shell 基本概述

    SHELL的概念 SHELL是一个命令行解释器,它为用户提供了一个向Linux内核发送请求以便运行程序的界面系统级程序, 用户可以用shell来启动,挂起,停止甚至是编写一些程序. ​ Shell还是 ...

  9. 关于java Collections.sort 排序

    public static void main(String[] args) { int[] dd = {12,34,46,123,23,2,35,13,543231,65,5645,57}; Arr ...

  10. .clearfix:after(清除浮动)中各个属性及值详细解说

    清除浮动.clearfix:after一词,从事web前端的朋友们对此不会陌生吧,下面为大家介绍的是.clearfix:after中用到的所有属性及值的含义,对此感兴趣的朋友可以参考下哈想,希望对大家 ...