【CQ18高一暑假前挑战赛3.5】标程
【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】标程的更多相关文章
- 【CQ18高一暑假前挑战赛5】标程
[A:暴力] #include<bits/stdc++.h> using namespace std; ; int a[maxn],vis[maxn],N,M; int main() { ...
- 【CQ18高一暑假前挑战赛4】标程
[二分或者STL] 二分: #include<bits/stdc++.h> using namespace std; ; int a[maxn]; int main() { ,pos; s ...
- 【CQ18高一暑假前挑战赛3】标程
[A:LCM] #include<bits/stdc++.h> using namespace std; #define ll long long int main() { ll a,b, ...
- 【CQ18高一暑假前挑战赛2】标程
[昨晚打校赛,5个小时打完很累了,所以搞忘出题了...对不起学弟们,不过出的题都亲自写过一遍,可以保证题目和代码长度都不长,题目难度不大] [A:bush博弈] #include<bits/st ...
- 【CQ18高一暑假前挑战赛1】标程
[A] #include<bits/stdc++.h> using namespace std; #define ll long long ll qpow(ll a,ll x,ll Mod ...
- [转]关于一些SPFA的标程
SPFA算法 求单源最短路的SPFA算法的全称是:Shortest Path Faster Algorithm. 最短路径快速算法-SPFA算法是西南交通大学段凡丁于1994年发表的. 适用范围:给定 ...
- [求助][SPOJ MARIOGAM]-高斯消元(内含标程,数据等)
小蒟蒻开始做概率的题之后,遇到了这道题,然而,他发现自己的程序调试了无数次也无法通过,系统总是返回令人伤心的WA, 于是,他决定把这一天半的时间收集到的资料放在网上, 寻求大家的帮助, 也可以节省后来 ...
- hdu6435 Problem J. CSGO标程讲解以及改正标程的一个错误(本来第一个样例过不了2333) 以及 poj2926 五维曼哈顿距离模板
比赛的时候抄poj2926的模板,但改不来啊orz #include <iostream> #include <cstdio> #include <cstring> ...
- 暑假前的flag
暑假到了,为了简便新开了一个博客,供暑假刷体放一些题解,玩acm1年多了,cf还是蓝名,真是菜的一笔,明年就大三了,马上就要毕业了,然而还是啥也不会,兼职和智障没什么两样,当初大一吹的牛逼说要成为学校 ...
随机推荐
- iOS -- SKViedoNode类
SKViedoNode类 继承自 SKNode:UIResponder:NSObject 符合 NSCoding(SKNode)NSCopying(SKNode)NSObject(NSObject) ...
- 实机桌面上给虚拟机安装系统(分区,恢复GHO)
在虚拟机里安装系统大家都会了.我这里介绍一种方法无须进入虚拟机里操作.全部在实机里完成对虚拟机安装系统(分区.恢复GHO).这里要使用到的工具如下1分区工具DISKGENIUS2虚拟光驱3Ghost镜 ...
- [反汇编练习] 160个CrackMe之029
[反汇编练习] 160个CrackMe之029. 本系列文章的目的是从一个没有任何经验的新手的角度(其实就是我自己),一步步尝试将160个CrackMe全部破解,如果可以,通过任何方式写出一个类似于注 ...
- DevExpress.XtraGrid 【转】
http://www.cnblogs.com/zeroone/p/4574539.html DevExpress.XtraGrid控件使用 该控件类是一个表格控件,但是其具有很多方便而使用的功能,例如 ...
- 第十讲_图像检索 Image Retrieval
第十讲_图像检索 Image Retrieval 刚要 主要是图像预处理和特征提取+相似度计算 相似颜色检索 算法结构 颜色特征提取:统计图片的颜色成分 颜色特征相似度计算 色差距离 发展:欧式距离- ...
- xgboost的SparkWithDataFrame版本实现
再xgboost的源码中有xgboost的SparkWithDataFrame的实现,如下:https://github.com/dmlc/xgboost/tree/master/jvm-packag ...
- python读取txt、csv和excel文件
一.python读取txt文件:(思路:先打开文件,读取文件,最后用for循环输出内容) fp = open('test.txt','r') lines = fp.readlines() fp.clo ...
- HEVC的參考队列解码
參考队列是指在进行帧间解码时.P或者B slice所參考的已解码的.位于解码图像缓存中(DPB, decoded picture buffer)中的图像队列,类似h264中的reflist0和refl ...
- VUE高仿饿了么app开发思维导图
来自互联网 文章来源:刘俊涛的博客 地址:http://www.cnblogs.com/lovebing
- 用ELK 实时处理搜索日志
转载请标明原处:http://blog.csdn.net/hu948162999/article/details/50563110 本来这块业务 是放到SolrCloud上去的 , 然后 採用solr ...