题意:中文题自己看吧

分析:这题分两步

第一步:利用已知公式求出k;

第二步:求出k然后使用欧拉降幂公式即可,欧拉降幂公式不需要互质(第二步就是BZOJ3884原题了)

求k的话就需要构造了(引入官方题解)

然后就求出k了,我就很奇怪为什么是这个式子,然后就网上搜啊搜

找到了一个推导(看完了以后恍然大悟)

推导链接:http://blog.csdn.net/wust_zzwh/article/details/51966450

高度仰慕数学好的巨巨

吐槽:这个题n是无平方因子,然后就要往欧拉函数是积性函数的性质上想,但是主要是还是要多做数学题

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <stack>
#include <map>
using namespace std;
typedef long long LL;
const int N = 1e7+;
const int mod=1e9+;
bool check[N];
LL phi[N],prime[N>>],tot;
LL sum[N],k,n,m,p;
LL qpow(LL a,LL b,LL mod){
LL ret=;
while(b){
if(b&)ret=(ret*a)%mod;
a=(a*a)%mod;
b>>=;
}
return ret;
}
void getphi(){
phi[]=;tot=;
for(int i=;i<=N-;++i){
if(!check[i]){
prime[++tot]=i;
phi[i]=i-;
}
for(int j=;j<=tot;++j){
if(i*prime[j]>N-)break;
check[i*prime[j]]=true;
if(i%prime[j]==){
phi[i*prime[j]]=phi[i]*prime[j];
break;
}
else phi[i*prime[j]]=phi[i]*(prime[j]-);
}
}
for(int i=;i<=N-;++i){
sum[i]=(sum[i-]+phi[i])%mod;
}
}
LL solve(LL n,LL m){
if(m==)return ;
if(m==)return phi[n];
if(n==)return sum[m];
if(phi[n]==n-){
return (phi[n]*solve(,m)%mod+solve(n,m/n))%mod;
}
for(int i=;i<=tot&&prime[i]*prime[i]<=n;++i){
if(n%prime[i])continue;
return (phi[prime[i]]*solve(n/prime[i],m)%mod+solve(n,m/prime[i]))%mod;
}
}
LL f(LL x){
if(x==)return ;
return qpow(k,f(phi[x])+phi[x],x);
}
int main(){
getphi();
while(~scanf("%I64d%I64d%I64d",&n,&m,&p)){
k=solve(n,m);
printf("%I64d\n",f(p));
}
return ;
}

HDU 5278 PowMod 数论公式推导的更多相关文章

  1. HDU 5728 - PowMod

    HDU 5728 - PowMod 题意:    定义: k = ∑(i=1,m) φ(i∗n) mod 1000000007 给出: n,m,p ,且 n 无平方因子 求: ans= k^(k^(k ...

  2. 2015多校第8场 HDU 5382 GCD?LCM! 数论公式推导

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5382 题意:函数lcm(a,b):求两整数a,b的最小公倍数:函数gcd(a,b):求两整数a,b的最 ...

  3. 数学--数论--HDU 2802 F(N) 公式推导或矩阵快速幂

    Giving the N, can you tell me the answer of F(N)? Input Each test case contains a single integer N(1 ...

  4. hdu GuGuFishtion 6390 数论 欧拉函数

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=6390 直接开始证明: 我们设…………………………………….....…...............………… ...

  5. HDU 1299 基础数论 分解

    给一个数n问有多少种x,y的组合使$\frac{1}{x}+\frac{1}{y}=\frac{1}{n},x<=y$满足,设y = k + n,代入得到$x = \frac{n^2}{k} + ...

  6. HDU 5317 RGCDQ (数论素筛)

    RGCDQ Time Limit: 3000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Submit Status ...

  7. hdu 5278 Geometric Progression 高精度

    Geometric Progression Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://bestcoder.hdu.edu.cn/contes ...

  8. HDU 1495 非常可乐(数论,BFS)

    非常可乐 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  9. HDU 1722 Cake (数论 gcd)(Java版)

    Big Number 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1722 ——每天在线,欢迎留言谈论. 题目大意: 给你两个数 n1,n2 . 然后 ...

随机推荐

  1. hdu1233

    http://acm.hdu.edu.cn/showproblem.php?pid=1233 最小生成树,kruskal算法 #include<stdio.h> #include<m ...

  2. 【tyvj】P1049 最长不下降子序列

    时间: 1000ms / 空间: 131072KiB / Java类名: Main 描述 求最长不下降子序列的长度 输入格式 第一行为n,表示n个数 第二行n个数 输出格式 最长不下降子序列的长度 测 ...

  3. 快速学习bootstrap前台框架

    W3c里的解释 使用bootstrap需要注意事项 1.  在html文件第一行要加上<!doctype html>[s1] 2.  导入bootstrap.min.css文件 3.  导 ...

  4. Java学习笔记之:Java 接口

    一.引言 接口(英文:Interface),在JAVA编程语言中是一个抽象类型,是抽象方法的集合,接口通常以interface来声明.一个类通过继承接口的方式,从而来继承接口的抽象方法. 接口并不是类 ...

  5. MVC运行原理

    Global.asax Global.asax 文件,有时候叫做 ASP.NET 应用程序文件,提供了一种在一个中心位置响应应用程序级或模块级事件的方法.你可以使用这个文件实现应用程序安全性以及其它一 ...

  6. 受限波兹曼机导论Introduction to Restricted Boltzmann Machines

    Suppose you ask a bunch of users to rate a set of movies on a 0-100 scale. In classical factor analy ...

  7. php-resque 任务队列

    php-resque License : MIT Source Code Allo点评:php-resque是Ruby项目resque在php下的实现.虽然Gearman也是一个不错的选择,但是res ...

  8. Java中ArrayList和LinkedList区别

    ArrayList和LinkedList的大致区别如下:1.ArrayList是实现了基于动态数组的数据结构,LinkedList基于链表的数据结构. 2.对于随机访问get和set,ArrayLis ...

  9. Android新版本SDK打开旧版本项目报错解决

    1.Description Resource Path Location Type Unable to resolve target 'android-19 解决:打开project.properti ...

  10. Android的NDK开发(4)————JNI数据结构之JNINativeMethod

    转至:http://blog.csdn.net/conowen/article/details/7524744 1.JNINativeMethod 结构体的官方定义 typedef struct { ...