【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. maven运行update命令时报org/apache/maven/shared/filtering/MavenFilteringException错误

           在eclipse中对准项目运行maven->update project命令时报错:org/apache/maven/shared/filtering/MavenFiltering ...

  2. 很多shell命令后面的单横杠和双横杠,原来这个意思

    原文: https://blog.csdn.net/deyili/article/details/5471023 ------------------------------------------- ...

  3. [Hibernate开发之路](3)基础配置

    一 JDBC链接 通常你希望SessionFactory来为你创建和缓存(pool)JDBC连接. 假设你採用这样的方式, 仅仅须要例如以下例所看到的那样,打开一个Session: Session s ...

  4. Host Controller transport layer and AMPs

    The logical Host Controller Interface does not consider multiplexing/routing over the Host Controlle ...

  5. Food hub

    Work center List Tillage 耕作 Hand harvest 手工采收 Planting 种植 Cultivating 培养 Mulching 覆盖 Dig harvest 挖地采 ...

  6. iOS_隐藏顶部状态栏

    iOS6和iOS7在隐藏 Status Bar 三种方式比較: Storyboard 界面上选中UIViewController,最右边Simulated Metrics找到 Status Bar 设 ...

  7. who命令

    who1.c #include <stdio.h>#include <utmp.h>#include <fcntl.h>#include <unistd.h& ...

  8. MySQL插入数据性能调优

    插入数据性能调优总结: 1.SQL插入语句调优 2.如果是InnoDB引擎的话,尝试开启事务,批量提交 3.调整MySQl数据库配置     参考: 百度空间 - MySQL插入数据性能调优 CSDN ...

  9. Android摄像头採集的视频数据流怎样通过Socket实时发送到目标服务端

    分两块: 1.取得摄像头採集的视频流 2.发送到server端 protected MediaRecorder mMediaRecorder; private LocalServerSocket mL ...

  10. 使用Python处理Excel文件的一些代码示例

    笔记:使用Python处理Excel文件的一些代码示例,以下代码来自于<Python数据分析基础>一书,有删改 #!/usr/bin/env python3 # 导入读取Excel文件的库 ...