【A:快速幂相关】

#include<bits/stdc++.h>
using namespace std;
int qpow(int a,int x){
a%=;int res=; while(x){
if(x&) res=res*a%;
a=a*a%; x>>=;
} return res;
}
int main()
{
int N;
cin>>N;
cout<<qpow(N,N);
return ;
}

【B:位数相关】

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int qpow(int a,int x){
int res=; a%=; while(x){
if(x&) res=res*a%;
a=a*a%; x>>=;
}return res;
}
int main()
{
int T,Case=; ll N,K;
scanf("%d",&T);
while(T--){
scanf("%lld%lld",&N,&K);
double x=K*log10(N)-(ll)(K*log10(N));
x=pow(10.0,x);
printf("Case %d: %d %03d\n",++Case,(int)(100.0*x),qpow(N,K));
}
return ;
}

【C:Nim博弈相关】

#include<bits/stdc++.h>
using namespace std;
int main()
{
int N,x,ans=;
scanf("%d",&N);
while(N--){
scanf("%d",&x);
ans^=x;
}
if(!ans) puts("B");
else puts("A");
return ;
}

【D:分治相关】

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int Mod=1e9+;
ll qpow2(ll a,ll x){
ll res=; while(x){
if(x&) res=res*a%Mod;
a=a*a%Mod;x>>=;
}
return res;
}
ll qpow(ll N)
{
if(N==) return ;
ll res=;
if(N&){ res=qpow2(,N); N--; }
ll tmp=qpow(N/);
return (tmp+tmp*qpow2(,N/)%Mod+res)%Mod;
}
int main()
{
ll N,ans;
scanf("%lld",&N);
ans=(+qpow(N))%Mod;
printf("%lld\n",ans);
return ;
}

【E:组合数相关】Lucas+中国剩余定理

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
const int maxn=;
LL fac[maxn],mod[maxn],odd[maxn],M,Mod;
void factorial()
{
fac[]=; for(int i=;i<=Mod;i++) fac[i]=fac[i-]*i%Mod;
}
LL f_pow(LL a,LL x)
{
LL res=; a%=Mod;
while(x){ if(x&) res=res*a%Mod;a=a*a%Mod; x>>=; }return res;
}
LL C(LL n,LL m)
{
if(m>n) return ; return fac[n]*f_pow(fac[m]*fac[n-m]%Mod,Mod-)%Mod;
}
LL Lucas(LL n,LL m)
{
if(m==) return ; return C(n%Mod,m%Mod)*Lucas(n/Mod,m/Mod)%Mod;
}
LL mul(LL x,LL y,LL p)
{
LL res=;
while(y){
if(y&) res=(res+x)%p;y>>=;x=(x+x)%p;
}return res%p;
}
void China(int k)
{
LL ans=;
for(int i=;i<=k;i++){
Mod=mod[i];
ans=ans+mul(mul(M/mod[i],f_pow(M/mod[i],mod[i]-),M),odd[i],M);
//ans=ans+M/mod[i]*f_pow(M/mod[i],mod[i]-2)*odd[i]%M;
}printf("%lld\n",(ans+M)%M);
}
int main()
{
LL T,n,m,k;
scanf("%lld",&T);
while(T--){
M=;
scanf("%lld%lld%lld",&n,&m,&k);
for(int i=;i<=k;i++){
scanf("%d",&mod[i]);Mod=mod[i];M*=mod[i];
factorial();
odd[i]=Lucas(n,m)%Mod;
}
China(k);
}return ;
}

【CQ18高一暑假前挑战赛3.5】标程的更多相关文章

  1. 【CQ18高一暑假前挑战赛5】标程

    [A:暴力] #include<bits/stdc++.h> using namespace std; ; int a[maxn],vis[maxn],N,M; int main() { ...

  2. 【CQ18高一暑假前挑战赛4】标程

    [二分或者STL] 二分: #include<bits/stdc++.h> using namespace std; ; int a[maxn]; int main() { ,pos; s ...

  3. 【CQ18高一暑假前挑战赛3】标程

    [A:LCM] #include<bits/stdc++.h> using namespace std; #define ll long long int main() { ll a,b, ...

  4. 【CQ18高一暑假前挑战赛2】标程

    [昨晚打校赛,5个小时打完很累了,所以搞忘出题了...对不起学弟们,不过出的题都亲自写过一遍,可以保证题目和代码长度都不长,题目难度不大] [A:bush博弈] #include<bits/st ...

  5. 【CQ18高一暑假前挑战赛1】标程

    [A] #include<bits/stdc++.h> using namespace std; #define ll long long ll qpow(ll a,ll x,ll Mod ...

  6. [转]关于一些SPFA的标程

    SPFA算法 求单源最短路的SPFA算法的全称是:Shortest Path Faster Algorithm. 最短路径快速算法-SPFA算法是西南交通大学段凡丁于1994年发表的. 适用范围:给定 ...

  7. [求助][SPOJ MARIOGAM]-高斯消元(内含标程,数据等)

    小蒟蒻开始做概率的题之后,遇到了这道题,然而,他发现自己的程序调试了无数次也无法通过,系统总是返回令人伤心的WA, 于是,他决定把这一天半的时间收集到的资料放在网上, 寻求大家的帮助, 也可以节省后来 ...

  8. hdu6435 Problem J. CSGO标程讲解以及改正标程的一个错误(本来第一个样例过不了2333) 以及 poj2926 五维曼哈顿距离模板

    比赛的时候抄poj2926的模板,但改不来啊orz #include <iostream> #include <cstdio> #include <cstring> ...

  9. 暑假前的flag

    暑假到了,为了简便新开了一个博客,供暑假刷体放一些题解,玩acm1年多了,cf还是蓝名,真是菜的一笔,明年就大三了,马上就要毕业了,然而还是啥也不会,兼职和智障没什么两样,当初大一吹的牛逼说要成为学校 ...

随机推荐

  1. mac mysql忘记密码解决办法

    http://www.jb51.net/article/87580.htm http://blog.csdn.net/soft2buy/article/details/50223373

  2. Build FTP Server on Windows

    1. Use the self-ftp component service with windows control panel / program / start or close windows ...

  3. 一个Netfilter nf_conntrack流表查找的优化-为conntrack添加一个per cpu cache

    独悲须要忍受.快乐须要分享对Linux协议栈多次perf的结果,我无法忍受conntrack的性能,然而它的功能是如此强大,以至于我无法对其割舍,我想自己实现一个高速流表.可是我不得不抛弃依赖于con ...

  4. 百科知识 isz文件如何打开

    使用UltraISO可以打开

  5. Pro Android学习笔记(一三七):Home Screen Widgets(3):配置Activity

    文章转载仅仅能用于非商业性质,且不能带有虚拟货币.积分.注冊等附加条件.转载须注明出处http://blog.csdn.net/flowingflying/以及作者@恺风Wei. 通过widget定义 ...

  6. An unexpected error occured when contacting the server .

    I logged into to the arcsight command center ,however I found an unexpected error occurred when cont ...

  7. AMD单桥主板上电时序的详细解释

    3个待机条件: 1.桥需要得到待机电压:3.3V,1.5V/1.2V2.25M起振注:NV的RTC电路,一般不会导致时序故障,都可以出CPURST#3.PWRGD-SB(即INTEL芯片组的RSMRS ...

  8. [笔记] 精通正则表达式/Mastering Regular Expressions

    / 匹配<emphasis>这个tag标注的IP地址的RE:‘<emphasis>([0-9]+(\.[0-9]+){3})</emphasis>' / 锚定--a ...

  9. cvpr2017年的所有论文下载

    wget -c -N  --no-clobber --convert-links --random-wait -r -p -E -e robots=off -U mozilla   http://op ...

  10. 逆向project实战--Afkayas.1

    0x00 序言 去年玩了几个月的渗透測试,当初认为非常高端的样子.如今看来只是都是些小把戏,于是開始折腾逆向project. 学习过程中參考的是<逆向project核心原理>这本书.讲的非 ...