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 ...
随机推荐
- gearman参数说明
-b, –backlog=BACKLOG 连接请求队列的最大值 -d, –daemon Daemon 守护进程化 -f, –file-descriptors=FDS 可打开的文件描述符数量 -h, – ...
- virtio是啥子
这个山头今天好像要攻占下来了 guest os中的一些特权操作会被hypervhisor给接收,这里一个很重要的认识是:hypervisor是os的os,既然要访问资源,那么就需要经过整机资源的管理者 ...
- Delphi实现DBGrid Shift+鼠标左键单击 多选
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...
- 【C++】指针和引用
引用: 引用(reference)是为对象起了另外一个名字,引用类型应用(refers to)另外一种类型.通过将声明符写成&d的形式来定义引用类型,其中d是声明的变量名. 一般初始化变量时, ...
- 第92天:CSS3中颜色和文本属性
一.颜色的表示方式 1. rgba(255,0,0,0.1) rgba是代表Red(红色) Green(绿色) Blue(蓝色)和 Alpha透明度.虽然它有的时候被描述为一个颜色空间 新增了RGB ...
- An In-Depth Look at the HBase Architecture--转载
原文地址:https://www.mapr.com/blog/in-depth-look-hbase-architecture In this blog post, I’ll give you an ...
- 洛谷 P2015 二叉苹果树
老规矩,先放题面 题目描述 有一棵苹果树,如果树枝有分叉,一定是分2叉(就是说没有只有1个儿子的结点) 这棵树共有N个结点(叶子点或者树枝分叉点),编号为1-N,树根编号一定是1. 我们用一根树枝两端 ...
- 《Linux Shell 脚本攻略》读书笔记
本书主要讲解一些linux shell命令的用法,讲解一些shell的奇技淫巧. 第一章 小试牛刀 主要介绍一些基本shell指令 终端打印:echo.printf 别名:alias 终端处理工具:t ...
- MySQL中文全文检索demoSQL
一.概述 MySQL全文检索是利用查询关键字和查询列内容之间的相关度进行检索,可以利用全文索引来提高匹配的速度. 二.语法 MATCH (col1,col2,...) AGAINS ...
- 【HEOI 2018】林克卡特树
转载请注明出处:http://www.cnblogs.com/TSHugh/p/8776179.html 先说60分的.思路题解上很清晰: 问题似乎等价于选K+1条点不相交的链哎!F(x,k,0/1/ ...