【CQ18高一暑假前挑战赛3】标程
【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】标程的更多相关文章
- 【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.5】标程
[A:快速幂相关] #include<bits/stdc++.h> using namespace std; int qpow(int a,int x){ a%=;; while(x){ ...
- 【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还是蓝名,真是菜的一笔,明年就大三了,马上就要毕业了,然而还是啥也不会,兼职和智障没什么两样,当初大一吹的牛逼说要成为学校 ...
随机推荐
- 【js】小数点后保留两位小数
小数点后保留两位小数 dicountPrice.toFixed(2)
- OpenGL - Tessellation Shader 【转】
http://blog.sina.com.cn/s/blog_8c7d49f20102v4qm.html Patch is just an ordered list of vertices (在tes ...
- vue2.0 + vux (四)Home页
1.综合页(首页) Home.vue <!-- 首页 --> <template> <div> <!-- 顶部 标题栏 --> <app-head ...
- c语言-递推算法1
递推算法之一:倒推法 1.一般分析思路: if 求解初始条件F1 then begin { 倒推 } 由题意(或递推关系)确定最终结果Fn; 求出倒推关系式Fi-1 =G(Fi ); i=n; { 从 ...
- mysql大数据量下修改表结构的方法
http://www.blogjava.net/anchor110/articles/361152.html
- HDU 5667 :Sequence
Sequence Accepts: 59 Submissions: 650 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...
- Android - Activity定制横屏(landscape)显示
Activity定制横屏(landscape)显示 本文地址: http://blog.csdn.net/caroline_wendy Android横屏(landscape)显示: android ...
- Linux CenOS Python3 和 python2 共存
1.查看是否已经安装Python CentOS 7.2 默认安装了python2.7.5 因为一些命令要用它比如yum 它使用的是python2.7.5. 使用 python -V 命令查看一下是否安 ...
- 文件I/O相关函数
open()和openat()函数: #include <fcntl.h> // 成功返回文件描述符,出错返回-1 int open(const char *path, int oflag ...
- eclipse的快捷键(常用)
1. Ctrl+O 显示类中方法和属性的大纲,能快速定位类的方法和属性,在查找Bug时非常有用. 2. Ctrl+M 窗口最大化和还原,用户在窗口中进行操作时,总会觉得当前窗口小(尤其在编写代码时), ...