【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还是蓝名,真是菜的一笔,明年就大三了,马上就要毕业了,然而还是啥也不会,兼职和智障没什么两样,当初大一吹的牛逼说要成为学校 ...
随机推荐
- 5.【nuxt起步】-swiper组件
接下来是一个比较常用,也比较重要的组件 swiper,可以自行搜索 vue swiper,有很多开源组件,我这里就复用之前一个熟悉的, 1.新建component/banner.vue 刷新报错: 要 ...
- How to set the initial value of a select element using AngularJS ng-options & track by
原文: https://www.gurustop.net/blog/2014/01/28/common-problems-and-solutions-when-using-select-element ...
- [c#菜鸟]lambda表达式
what 一.定义 Lambda 表达式是一种可用于创建 委托 或 表达式目录树 类型的 匿名函数 .通过使用 lambda 表达式,可以写入可作为参数传递或作为函数调用值返回的本地函数.(微软) 理 ...
- mt-checklist 的 bug 解疑 及 防止 this 指针偏移
1.今天在使用 mt-checklist 时,发现 绑定 change 方法后,第一次点击返回的值为 空数组 <template> <div id="app"&g ...
- 修改Qweb报表
Table of Contents 将报表的类型改为HTML 打印HTML格式报表 使用html editor 修改报表模板 使用Web builder修改报表 恢复报表格式 将报表的 ...
- Windows 编程1
杀死一个进程 使用命令 system( taskkill /f /im QQ.exe); 即可. 打开一个进程 使用命令 system("应用程序的位置"); 头文件: ...
- 苦逼IT才能看懂的笑话
这是苦逼IT才能看懂的笑话1.栈和队列的区别是啥? 吃多了拉就是队列:吃多了吐就是栈 2.世界上最遥远的距离不是生与死,而是你亲手制造的BUG就在你眼前,你却怎么都找不到她... 3.<c++程 ...
- VCC/AVCC/VDD/AVDD区别
V*与AV*的区别是:数字与模拟的区别CC与DD的区别是:供电电压与工作电压的区别(通常VCC>VDD): 数字电路供电VCC 模拟电路供电AVCCVDD是指工作电压,就是供电进芯片的 AVDD ...
- 网页编程-Django(一)
业内: GET:获取数据 POST:提交数据 上传单个数据: request.POST.get(‘’name名‘’) 上传多选数据: request.POST.getlist('name名') 上传文 ...
- Spring的常见问题及答案
目录 Spring 概述 依赖注入 Spring beans Spring注解 Spring数据访问 Spring面向切面编程(AOP) Spring MVC Spring 概述 1. 什么是spri ...