数论板子合集。。。

我们要求:

$N^{\sum\limits_{i=1}^{N}[gcd(i,N)==1]C_{n}^{i}}mod p$

其中p为54184622,是个合数

指数是组合数,不能用快速幂,只能mod phi(p),phi(p)=p-1,而p-1不是质数,要用crt合并

#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#define mod 54184622
#define int long long
#define MAXN 1000005
using namespace std;
int n,g,a[7],prime[7]={0,2,3,5,7,129011};
int fac[7][MAXN],ans;
int q_pow(int a,int b,int p){
int res=1;
while(b){
if(b&1) res=(res*a)%p;
a=(a*a)%p;
b>>=1;
}
return res%p;
}
int gcd(int a,int b){
return b==0?a:gcd(b,a%b);
}
int C(int n,int m,int p){
if(n==m) return 1;
if(m>n) return 0;
return fac[p][n]*q_pow(fac[p][m]*fac[p][n-m]%prime[p],prime[p]-2,prime[p]);
}
int lucas(int n,int m,int p){
if(m==0) return 1;
return lucas(n/prime[p],m/prime[p],p)%mod*C(n%prime[p],m%prime[p],p)%prime[p];
}
int crt(){
int p=27092310,res=0;
for(int i=1;i<=5;i++)
res=(res+p/prime[i]*a[i]%p*q_pow(p/prime[i],prime[i]-2,prime[i])%p)%p;
return res;
}
signed main(){
scanf("%lld %lld",&n,&g);
for(int i=1;i<=5;i++){
fac[i][0]=1;
for(int j=1;j<=prime[i];j++)
fac[i][j]=fac[i][j-1]*j%prime[i];
}
for(int i=1;i<=min(n,g);i++){
if(gcd(i,n)!=1) continue;
for(int j=1;j<=5;j++){
a[j]=(a[j]+lucas(g,i,j))%prime[j];
}
}
ans=crt();
printf("%lld\n",q_pow(n,ans,mod));
return 0;
}

HZOI20190823 C magic的更多相关文章

  1. Codeforces CF#628 Education 8 D. Magic Numbers

    D. Magic Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  2. [8.3] Magic Index

    A magic index in an array A[0...n-1] is defined to be an index such that A[i] = i. Given a sorted ar ...

  3. Python魔术方法-Magic Method

    介绍 在Python中,所有以"__"双下划线包起来的方法,都统称为"Magic Method",例如类的初始化方法 __init__ ,Python中所有的魔 ...

  4. 【Codeforces717F】Heroes of Making Magic III 线段树 + 找规律

    F. Heroes of Making Magic III time limit per test:3 seconds memory limit per test:256 megabytes inpu ...

  5. 2016中国大学生程序设计竞赛 - 网络选拔赛 C. Magic boy Bi Luo with his excited tree

    Magic boy Bi Luo with his excited tree Problem Description Bi Luo is a magic boy, he also has a migi ...

  6. 一个快速double转int的方法(利用magic number)

    代码: int i = *reinterpret_cast<int*>(&(d += 6755399441055744.0)); 知识点: 1.reinterpret_cast&l ...

  7. MAGIC XPA最新版本Magic xpa 2.4c Release Notes

    New Features, Feature Enhancements and Behavior ChangesSubforms – Behavior Change for Unsupported Ta ...

  8. Magic xpa 2.5发布 Magic xpa 2.5 Release Notes

    Magic xpa 2.5發佈 Magic xpa 2.5 Release Notes Magic xpa 2.5 Release NotesNew Features, Feature Enhance ...

  9. How Spring Boot Autoconfiguration Magic Works--转

    原文地址:https://dzone.com/articles/how-springboot-autoconfiguration-magic-works In my previous post &qu ...

随机推荐

  1. [JZOJ6278] 2019.8.5【NOIP提高组A】跳房子

    题目 题目大意 给你一个矩阵,从\((1,1)\)开始,每次往右上.右.右下三个格子中权值最大的那个跳. 第一行上面是第\(n\)行,第\(m\)列右边是第\(1\)列.反之同理. 有两个操作:跳\( ...

  2. 1003CSP-S模拟测试赛后总结

    我是垃圾……我只会骗分. 拿到题目通读一遍,感觉T3(暴力)是个树剖+线段树. 刚学了树刨我这个兴奋啊.然而手懒决定最后再说. 对着T1一顿yyxjb码了个60pts的测试点分治就失去梦想了.(顺便围 ...

  3. CNN 常用的几个模型

    LeNet5 论文:http://yann.lecun.com/exdb/publis/pdf/lecun-01a.pdf LeNet-5:是Yann LeCun在1998年设计的用于手写数字识别的卷 ...

  4. h5判断是否为iphonex

    js移动端页面判断是否是iphoneX 转自https://blog.csdn.net/weixin_39924326/article/details/80352929 function isIPho ...

  5. System.Web.Mvc.HttpGetAttribute.cs

    ylbtech-System.Web.Mvc.HttpGetAttribute.cs 1.程序集 System.Web.Mvc, Version=5.2.3.0, Culture=neutral, P ...

  6. hexo next主题中遇到的关于require的timeout的问题。Uncaught Error: Load timeout for modules:

    个人博客:https://mmmmmm.me 源码:https://github.com/dataiyangu/dataiyangu.github.io 背景 报错:Uncaught Error: L ...

  7. npm使用入门

    NPM使用入门 npm 就是node package manager node的包管理工具 我们通过npm install 模块 来安装模块,缩写:npm i 模块,注意,低版本的node可能需要np ...

  8. <Python基础>字典的基本操作

    ''' 小知识 1.字典的键只能是不可变数据类型:int 元组 bool str(可哈希) 字典查找数据会使用二分查找,会先用哈希表将键转化为数字然后进行查找 ''' s = { "name ...

  9. 判断Paging File 的方法

    当前环境,MiniFilter 1:FsRtlIsPagingFile 参数是一个 FileObject 2:判断操作标识   SL_OPEN_PAGING_FILE FlagOn 宏可以直接做到,传 ...

  10. Tomcat的优化技巧

    (1)参数 minProcessors:最小空闲连接线程数,用于提高系统处理性能,默认值为10. maxProcessors:最大连接线程数,即:并发处理的最大请求数,默认值为75. acceptCo ...