【A】

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

【B】

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll N,ans;
cin>>N;
ans=N;
ans-=N/;
ans-=N/;
ans-=N/;
ans-=N/; ans+=N/(*);
ans+=N/(*);
ans+=N/(*);
ans+=N/(*);
ans+=N/(*);
ans+=N/(*); ans-=N/(**);
ans-=N/(**);
ans-=N/(**);
ans-=N/(**); ans+=N/(***);
cout<<ans<<endl;
return ;
}

【C】

#include<bits/stdc++.h>
using namespace std;
const int maxn=;
char c[maxn];
int dp[maxn][maxn];
int main()
{
scanf("%s",c+);
int L=strlen(c+),i,j;
for(i=L;i>=;i--){
for(j=i;j<=L;j++){
if(j-i+==) dp[i][j]=;
else if(j-i+==) dp[i][j]=(c[i]==c[j]?:);
else {
dp[i][j]=min(dp[i+][j],dp[i][j-])+;
if(c[i]==c[j]) dp[i][j]=min(dp[i][j],dp[i+][j-]);
}
}
}
cout<<dp[][L]<<endl;
return ;
}

【D】

#include<bits/stdc++.h>
using namespace std;
const int maxn=;
int a[maxn],rt[maxn],cnt;
struct node{
int l,r,val;
node(){ l=r=val=; }
node(int L,int R,int V):l(L),r(R),val(V){}
}s[maxn*];
void add(int &now,int pre,int x,int pos)
{
now=++cnt;
s[now]=node(s[pre].l,s[pre].r,s[pre].val+);
if(pos==-) return ;
if(((x>>pos)%)==) add(s[now].l,s[pre].l,x,pos-);
else add(s[now].r,s[pre].r,x,pos-);
}
int query(int now,int pre,int x)
{
int res=;
for(int i=;i>=;i--){
int t=(x>>i)%;
if(t==){
if(s[now].r&&s[s[now].r].val-s[s[pre].r].val>) now=s[now].r, pre=s[pre].r, res+=(<<i);
else if(s[now].l) now=s[now].l, pre=s[pre].l;
else break;
}
if(t==){
if(s[now].l&&s[s[now].l].val-s[s[pre].l].val>) now=s[now].l, pre=s[pre].l, res+=(<<i);
else if(s[now].r) now=s[now].r, pre=s[pre].r;
else break;
}
}
return res;
}
int main()
{
int N,Q,L,R,x,i;
scanf("%d%d",&N,&Q);
for(i=;i<=N;i++){
scanf("%d",&a[i]);
add(rt[i],rt[i-],a[i],);
}
for(i=;i<=Q;i++){
scanf("%d%d%d",&x,&L,&R);
int ans=query(rt[R+],rt[L],x);
printf("%d\n",ans);
}
return ;
}

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

  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.5】标程

    [A:快速幂相关] #include<bits/stdc++.h> using namespace std; int qpow(int a,int x){ a%=;; while(x){ ...

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

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

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

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

  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. [c++菜鸟]《Accelerate C++》习题解答

    第0章 0-0 编译并运行Hello, world! 程序. #include <iostream> using namespace std; int main() { cout < ...

  2. c# Dictionary拓展2个key得到1个value

    using System.Collections.Generic; using System.Collections; Dictionary<Tuple<int, int>, int ...

  3. 关于JavaScript禁止点击事件

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. GB28181对接视频流

    今天抽空写下以GB28181的方式获取摄像机视频流以备后用,同时也希望能帮助到正着手开发GB28181对接视频的同学,这块的资料实在不多. 今天讲的内容不涉及到平台对接,平台对接下次有时间再讲,平台对 ...

  5. UDIMM、RDIMM、SODIMM以及LRDIMM的区别

    DIMM简介 DIMM(Dual Inline Memory Module,双列直插内存模块)与SIMM(single in-line memory module,单边接触内存模组)相当类似,不同的只 ...

  6. centos创建本地yum仓库

    怎样发布自己软件的安装和更新YUM源 在创建之前,我们先了解些相关的内容: yum仓库可以支持三种途径提供给yum在安装的时候下载rpm包 第一种:  ftp服务  ftp:// 第二种:  http ...

  7. PHP中使用Redis

    Redis是什么 Redis ( REmote DIctionary Server ) , 是一个由Salvatore Sanfilippo写的key-value存储系统. Redis是一个开源的使用 ...

  8. 不使用while,for,if等实现加法

    不使用if, while,for,switch等实现从1到10的加法 解:这里使用静态函数和静态变量实现,利用类似的方法也能够实现从1打印到1000 class TheSum{ public: The ...

  9. kubernetes之故障现场二,节点名称冲突

    系列目录 问题描述:测试环境由于异常断电导致服务器重启一后,有一个节点的状态一直是NotReady.通过journalctl -f -u kubelet没有错误日志输出.通过tail /var/log ...

  10. 小printf的故事:什么是真正的程序员?

    http://kb.cnblogs.com/page/570194/ 作者: 削微寒  来源: 博客园  发布时间: 2017-06-06 10:03  阅读: 33004 次  推荐: 98   原 ...