2017 ACM暑期多校联合训练 - Team 3 1008 HDU 6063 RXD and math (莫比乌斯函数)
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
分析:
u()函数是莫比乌斯函数,这个不影响做题,这个式子算的是[1,nk]中能够写成(a×b2)的数的个数,其中|u(a)|=1.然后我们可以证明任何数都可以唯一写成(a×b^2)的形式,因为(b = p1p2..pn),假设(a)中没有(b)中的因子,那么肯定是唯一表示的,如果(a)中含有(b)中的因子,改变表示的形式,那么肯定要将(b)改变,假设将任意一个(p)和(a)中的某个不在(b)中的质因子互换时,由于(p)无论在(a)中本来有或没都无法构成平方,所以无法互换,表达形式唯一。以这个式子会把[1, n^k]的每个整数恰好算一次. 所以答案就是n^k。
或则可以直接自己打表看一下简单的规律,比赛的时候就是自己写了几组数据找出来的规律。
#include<iostream>
#include<stdio.h>
typedef long long ll;
const int mod=1e9+7;
ll n,k;
using namespace std;
void solve(ll n,ll k)
{
ll ans=1;
ll res=n;
while(k)
{
if(k&1)
ans=((ans%mod)*(res%mod))%mod;
res=((res%mod)*(res%mod))%mod;
k>>=1;
}
printf("%lld\n",ans);
}
int main()
{
int Case=1;
while(~scanf("%lld%lld",&n,&k))
{
printf("Case #%d: ",Case++);
solve(n,k);
}
return 0;
}
2017 ACM暑期多校联合训练 - Team 3 1008 HDU 6063 RXD and math (莫比乌斯函数)的更多相关文章
- 2017 ACM暑期多校联合训练 - Team 9 1008 HDU 6168 Numbers (模拟)
题目链接 Problem Description zk has n numbers a1,a2,...,an. For each (i,j) satisfying 1≤i<j≤n, zk gen ...
- 2017 ACM暑期多校联合训练 - Team 5 1008 HDU 6092 Rikka with Subset (找规律)
题目链接 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, s ...
- 2017 ACM暑期多校联合训练 - Team 4 1007 HDU 6073 Matching In Multiplication (模拟)
题目链接 Problem Description In the mathematical discipline of graph theory, a bipartite graph is a grap ...
- 2017 ACM暑期多校联合训练 - Team 4 1012 HDU 6078 Wavel Sequence (模拟)
题目链接 Problem Description Have you ever seen the wave? It's a wonderful view of nature. Little Q is a ...
- 2017ACM暑期多校联合训练 - Team 8 1008 HDU 6140 Hybrid Crystals (模拟)
题目链接 Problem Description Kyber crystals, also called the living crystal or simply the kyber, and kno ...
- 2017ACM暑期多校联合训练 - Team 7 1008 HDU 6127 Hard challenge (极角排序)
题目链接 Problem Description There are n points on the plane, and the ith points has a value vali, and i ...
- 2017ACM暑期多校联合训练 - Team 6 1008 HDU 6103 Kirinriki (模拟 尺取法)
题目链接 Problem Description We define the distance of two strings A and B with same length n is disA,B= ...
- 2017ACM暑期多校联合训练 - Team 2 1008 HDU 6052 To my boyfriend (数学 模拟)
题目链接 Problem Description Dear Liao I never forget the moment I met with you. You carefully asked me: ...
- 2017ACM暑期多校联合训练 - Team 4 1004 HDU 6070 Dirt Ratio (线段树)
题目链接 Problem Description In ACM/ICPC contest, the ''Dirt Ratio'' of a team is calculated in the foll ...
随机推荐
- BETA预发布演示视频
视频连接:优酷http://v.youku.com/v_show/id_XMTgxMjQxMjc0NA==.html?from=y1.7-2
- django学习系列-01
安装Django > pip install django==1.10.3(py2)或者>python3 -m pip install django==1.10.3(py3) 成功安装 D ...
- WPF中Image控件的Source属性的设置
1.直接关联到文件,关联后不能删除此图片,因为图片正在使用. imageEditImage.Source = new BitmapImage(new Uri(strImagePath, UriKind ...
- Python中int()函数的用法浅析
int()是Python的一个内部函数 Python系统帮助里面是这么说的 >>> help(int) Help on class int in module __builti ...
- Red Hat下升级python的问题
分为两部分: 一,升级Python 安装的包的渠道(传送门),安装过程的渠道(传送门). 二.涉及的问题 1.yum不能使用 解决办法(传送门),其中的部分就行.
- SVN Server 500 NotLicensed 错误的解决方法
SVN Server 500 NotLicensed 错误的HTML页面显示 Not licensed The server encountered an internal error or misc ...
- isNaN与parseInt/parseFloat
isNaN 返回一个 Boolean 值,指明提供的值是否是保留值 NaN (不是数字). NaN 即 Not a Number isNaN(numValue) 必选项 numvalue 参数为要检查 ...
- Nginx修改access.log日志时间格式
一.修改原因 因为要获取nginx访问信息,作为开发的数据使用,但是nginx的access.log文件中的默认的时间格式是这样的: [02/Nov/2017:20:48:25 +0800] 而要求的 ...
- 「Django」学习之路,持续更改
一.setting设置 1.设置 局域网可以部署连接 ALLOWED_HOSTS = ['*.besttome.com','192.168.1.100'] 2.static配置 STATIC_URL ...
- API图片路径和超链接语义化转换
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...