【A:LCM】

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

【B:STL,用set或者queue+map都行】

#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
const int maxn=;
const ll inf=1e18;
ll a[maxn]; int cnt;
set<ll>s;
void solve()
{
s.insert(); s.insert(); s.insert();
while(!s.empty()){
ll now=*s.begin();
a[++cnt]=now; s.erase(s.begin());
if(now*<=inf) s.insert(now*);
if(now*<=inf) s.insert(now*);
if(now*<=inf) s.insert(now*);
}
}
int main()
{
solve();
int T; ll N;
scanf("%d",&T);
while(T--){
scanf("%lld",&N);
int pos=lower_bound(a+,a+cnt+,N)-a;
printf("%lld\n",a[pos]);
}
return ;
}

【C:贪心水题】

#include<bits/stdc++.h>
using namespace std;
const int maxn=;
int a[maxn];
int main()
{
int N,M,i,j,ans=;
scanf("%d%d",&N,&M);
for(i=;i<=N;i++) scanf("%d",&a[i]);
sort(a+,a+N+);
j=;
for(i=N;i>=j;i--){
if(i!=j&&a[i]+a[j]<=M) j++;
ans++;
}
printf("%d\n",ans);
return ;
}

【D:暴力求得每个数的因子,复杂度O(Nsqrrt(N))】

#include<bits/stdc++.h>
using namespace std;
const int maxn=;
int num[maxn];
int main()
{
int N,x,i,j,ans=;
scanf("%d",&N);
for(i=;i<=N;i++){
scanf("%d",&x);
for(j=;j*j<=x;j++){
if(x%j==){
num[j]++; if(num[j]>) ans=max(ans,j);
if(j*j!=x) {
num[x/j]++; if(num[x/j]>) ans=max(ans,x/j);
}
}
}
}
printf("%d\n",ans);
return ;
}

【E:区间DP,和前天那个有点像】

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=;
ll sum[maxn][maxn];
int ans,x;
int main()
{
int N,M,i,j,k;
while(~scanf("%d%d",&M,&N)){
ans=;
for(i=;i<=N;i++)
for(j=;j<=M;j++)
scanf("%d",&x),sum[i][j]=sum[i-][j]+x;
for(i=;i<=N;i++)
for(j=i;j<=N;j++){
int tmp=;
for(k=;k<=M;k++){
tmp+=sum[j][k]-sum[i-][k];
if(tmp<) tmp=;
if(tmp>ans) ans=tmp;
}
}
printf("%d\n",ans);
}
return ;
}

【F:KMP】

请先自学吧。

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

  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高一暑假前挑战赛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. lstm公式推导

    http://blog.csdn.net/u010754290/article/details/47167979 导言 在Alex Graves的这篇论文<Supervised Sequence ...

  2. mac 安装scrapy

    https://jingyan.baidu.com/article/14bd256e748346bb6d2612be.html 1.安装Python 安装完了记得配置环境,将python目录和pyth ...

  3. ASP复制文件

    <% dim fs,oldpath,newpath Set fs=Server.CreateObject("Scripting.FileSystemObject") oldp ...

  4. 自己写的通过ADO操作mysql数据库

    #include <iostream> #include <windows.h> #include <atlstr.h> #import "c:\Prog ...

  5. Solaris 下解决上网问题以及远程登录问题

    解决乱码问题 参考文章 http://www.jb51.net/os/Solaris/1656.html solaris 显示乱码的解决方法 现象: 利用命令 : LANG=zh; export LA ...

  6. 使用CCriticalSection类的注意事项

    在类中使用CCriticalSection变量时,必需要将CCriticalSection变量定义为全局变量和静态变量,否则将出现没有定义的错误. 如: // a.h 文件 class A:publi ...

  7. 重置浏览器的默认样式(css reset)

    (1)定义:首先css reset指的是重置浏览器的默认样式 (2)作用:因为现在的浏览器很多,并且每个浏览器都有自己的默认样式,这样就会导致一个页面在多个浏览器下展示产生差异,所以我们需要做一些处理 ...

  8. OpenGL 与 GLSL 版本号

    来自:https://github.com/mattdesl/lwjgl-basics/wiki/GLSL-Versions You can use the #version command as t ...

  9. centos7下MySQL的配置

    1. 下载mysql的repo源 wget http:.noarch.rpm 2. 安装mysql-community-release-el7-5.noarch.rpm包 rpm .noarch.rp ...

  10. caffe训练自己的图片进行分类预测--windows平台

    caffe训练自己的图片进行分类预测 标签: caffe预测 2017-03-08 21:17 273人阅读 评论(0) 收藏 举报  分类: caffe之旅(4)  版权声明:本文为博主原创文章,未 ...