题目链接

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 (莫比乌斯函数)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 2017ACM暑期多校联合训练 - Team 8 1008 HDU 6140 Hybrid Crystals (模拟)

    题目链接 Problem Description Kyber crystals, also called the living crystal or simply the kyber, and kno ...

  6. 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 ...

  7. 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= ...

  8. 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: ...

  9. 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 ...

随机推荐

  1. HTTP协议 结构,get post 区别(阿里面试)

    如果需要想了解相关的TCP的协议结构,底层架构,以及每次面试必问的三次握手,四次挥手可以 参考:TCP协议详解7层和4层解析(美团面试,阿里面试) 尤其是三次握手,四次挥手 具体发送的报文和状态都要掌 ...

  2. 第149天:javascript中this的指向详解

    js中的this指向十分重要,了解js中this指向是每一个学习js的人必学的知识点,今天没事,正好总结了js中this的常见用法,喜欢的可以看看: 1.全局作用域或者普通函数中this指向全局对象w ...

  3. java 父类的引用调用自己的属性 但是调用的方法必须是重写过的父类的方法 因为编译时候把他当作父类 运行时候才是他自己 所以必须重写父类得方法

  4. BZOJ 2467 生成树(组合数学)

    题意:求n-五边形的生成树个数. 结论题,答案为4*n*5^(n-1). 首先中心的n边形一定需要切掉一个边,C(1,n). 然后每个五边形都切一个边,C(1,4)*5^(n-1). 于是答案就是4* ...

  5. 【开发工具IDE】Eclipse 安装 Maven 的 m2eclipse 插件

    本段节选自http://www.cnblogs.com/dcba1112/archive/2011/05/01/2033805.html Eclipse是一款非常优秀的IDE.除了基本的语法标亮.代码 ...

  6. [BZOJ4653][NOI2016]区间 贪心+线段树

    4653: [Noi2016]区间 Time Limit: 60 Sec  Memory Limit: 256 MB Description 在数轴上有 n个闭区间 [l1,r1],[l2,r2],. ...

  7. Linux内核设计第四周学习总结 使用库函数API和C代码中嵌入汇编代码两种方式使用同一个系统调用

    陈巧然原创作品 转载请注明出处 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 实验目的: 使用库函数A ...

  8. 解题:CTSC 2017 吉夫特

    题面 首先有个结论:$C_n^m$为奇数当且仅当$m$是$n$的一个子集 于是从后往前推,记录每个数出现的位置,然后对每个位置枚举子集统计在它后面的贡献即可 #include<cstdio> ...

  9. 【bzoj2844】albus就是要第一个出场

    Time Limit: 6 Sec  Memory Limit: 128 MBSubmit: 2254  Solved: 934[Submit][Status][Discuss] Descriptio ...

  10. java 根据包名、目录名获取所有定义的类

    /** * Scans all classes accessible from the context class loader which belong to the given package a ...