HDU - 6063 RXD and math
Bryce1010模板
http://acm.hdu.edu.cn/showproblem.php?pid=6063
打表发现规律是n^k
#include <iostream>
#include<string.h>
#include<cmath>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const int MAXN=1e6;
bool check[MAXN+10];
int prime[MAXN+10];
int mu[MAXN+10];
void moblus()
{
memset(check,false,sizeof(check));
mu[1]=1;
int tot=0;
for(int i=2;i<MAXN;i++)
{
if(!check[i])
{
prime[tot++]=i;
mu[i]=-1;
}
for(int j=0;j<tot;j++)
{
if(i*prime[j]>MAXN)break;
check[i*prime[j]]=true;
if(i%prime[j]==0)
{
mu[i*prime[j]]=0;
break;
}
else
{
mu[i*prime[j]]=-mu[i];
}
}
}
}
ll pow_mod(ll a,ll n,ll mod)
{
ll ret=1;
//ll tmp=a%mod;
a=a%mod;
while(n)
{
if(n&1)ret=(ret*a)%mod;
a=a*a%mod;
n>>=1;
}
return ret%MOD;
}
int main()
{
ll n,k;
ll Case=1;
while(cin>>n>>k)
{
cout<<"Case #"<<Case++<<": "<<pow_mod(n,k,MOD)%MOD<<endl;
}
return 0;
}
HDU - 6063 RXD and math的更多相关文章
- HDU 6063 - RXD and math | 2017 Multi-University Training Contest 3
比赛时候面向过题队伍数目 打表- - 看了题解发现确实是这么回事,分析能力太差.. /* HDU 6063 - RXD and math [ 数学,规律 ] | 2017 Multi-Universi ...
- hdu 6063 RXD and math(快速幂)
RXD and math Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)To ...
- 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)×⌊nk ...
- 数学--数论--HDU 6063 RXD and math (跟莫比乌斯没有半毛钱关系的打表)
RXD is a good mathematician. One day he wants to calculate: output the answer module 109+7. p1,p2,p3 ...
- HDU 5628 Clarke and math——卷积,dp,组合
HDU 5628 Clarke and math 本文属于一个总结了一堆做法的玩意...... 题目 简单的一个式子:给定$n,k,f(i)$,求 然后数据范围不重要,重要的是如何优化这个做法. 这个 ...
- 2017 多校3 hdu 6061 RXD and functions
2017 多校3 hdu 6061 RXD and functions(FFT) 题意: 给一个函数\(f(x)=\sum_{i=0}^{n}c_i \cdot x^{i}\) 求\(g(x) = f ...
- HDU 6061 - RXD and functions | 2017 Multi-University Training Contest 3
每次NTT都忘记初始化,真的是写一个小时,Debug两个小时- - /* HDU 6061 - RXD and functions [ NTT ] | 2017 Multi-University Tr ...
- HDU 6060 - RXD and dividing | 2017 Multi-University Training Contest 3
/* HDU 6060 - RXD and dividing [ 分析,图论 ] | 2017 Multi-University Training Contest 3 题意: 给一个 n 个节点的树, ...
- RXD and math
RXD and math 题目链接 思路 \(u\)函数是莫比乌斯函数,这个不影响做题,这个式子算的是\([1,n^k]\)中能够写成\(a*b^2\)的数的个数,\(u(a)!=0\).然后我们可以 ...
随机推荐
- java乱炖
--------------------------------------------------------- ArrayList<String> arrayList = new Ar ...
- openwrt: patch-dtb
dts的概念是linux kernel中的,跟openwrt的关系不大.只是恰好在学习openwrt的时候碰到了这个东西,所以记录在openwrt名下. patch-dtb openwrt对arch/ ...
- LeetCode题解(14)--Longest Common Prefix
https://leetcode.com/problems/longest-common-prefix/ 原题: Write a function to find the longest common ...
- 【读书笔记】iOS-GCD-用法
代码: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { dispatch_async(dispatch_get_gl ...
- 两个月刷完Leetcode前400题经验总结
更新:气死了,挂个傻逼: 每次做个分享.组织个活动,就会有一些傻逼冒泡生怕别人不知道他是傻逼,气死我了!自己好好看看非法集资的概念,我办这个活动,一分钱都没收,入群99元是督促大家完成刷题任务,最后完 ...
- 在Qt Creator中为Qt工程添加资源
1.右键单击工程 -> Add New ... -> Qt -> Qt Resource File -> Choose... -> Name: -> Next -& ...
- 两篇C++和VC++字符串的文章
有空挨个摘录写点心得 http://www.cnblogs.com/maowang1991/p/3572304.html http://www.cnblogs.com/maowang1991/p/35 ...
- Android应用之——最新版本号SDK V2.4实现QQ第三方登录
为什么要写这篇博客呢?由于.我在做这个第三方登录的时候,找了非常多资料,发现要么就是过时了.要么就是说的非常不清楚.非常罗嗦.并且非常多都是一些小demo,不是什么实例.甚至连腾讯官方的文档都有这个问 ...
- 20170221 SE03 打包请求
请求处理:SE03 只会有其中两三个功能,还需要学习. 请求打包,是传输请求时候常用的一种方法. 步骤如下: 注意点:1.打包请求一定仔细检查,不要遗漏 如果请求不多,分开传是更好 ...
- NEU 1683: H-Index
题目描述 Given an array of citations (each citation is a non-negative integer) of a researcher, write a ...