【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还是蓝名,真是菜的一笔,明年就大三了,马上就要毕业了,然而还是啥也不会,兼职和智障没什么两样,当初大一吹的牛逼说要成为学校 ...
随机推荐
- PS 抠图如何使用通道法处理头发
通道抠图法抠出美女飘逸头发-PS抠图实例教程 抠图更换背景后效果图 通道抠图法抠出美女飘逸头发-PS抠图实例教程 教程步骤: 1 打开原图,进入通道面板. 通道抠图法抠出美女飘逸头发-PS抠图实 ...
- C#自定义类型数组排序
在数组或者集合中对自定义类型进行排序分为两种方法. 1.如果这个自定义类型是自己定义编写的,那么我可以使它继承ICompareable<T>接口,实现其中的CompareTo(Object ...
- JavaScript插件编写指南
在编写插件之前,大家要先了解做插件的几个要点: 插件需要满足的条件 一个可复用的插件需要满足以下条件: 插件自身的作用域与用户当前的作用域相互独立,也就是插件内部的私有变量不能影响使用者的环境变量: ...
- 新建 .NET Core 控制台项目 C# 数组深拷贝
新建 .NET Core 控制台项目 1. 安装 .NET Core SDK 1.0 参考微软官方网站 https://www.microsoft.com/net/download/windows 2 ...
- 基于tornado实现的web聊天室
目录结构: # -*- coding:utf-8 -*- import uuid import json import tornado.ioloop import tornado.web import ...
- Sum It Up POJ 1564 HDU 杭电1258【DFS】
Problem Description Given a specified total t and a list of n integers, find all distinct sums using ...
- EasyDarwin开源流媒体服务器支持basic基本认证和digest摘要认证解析
本文转自EasyDarwin开源团队成员ss的博客:http://blog.csdn.net/ss00_2012/article/details/52262621 RTSP认证作为RTSP标准协议的一 ...
- c/c++标准库中的文件操作总结
1 stdio.h是c标准库中的标准输入输出库 2 在c++中调用的方法 直接调用即可,但是最好在函数名前面加上::,以示区分类的内部函数和c标准库函数. 3 c标准输入输出库的使用 3.1 核心结构 ...
- 支付宝cookie 是支付密码 不是登录密码
开发文档/ 手机网站支付 / 产品介绍 开放平台文档中心 https://docs.open.alipay.com/203/105288
- Delphi快捷键大全
Delphi快捷键大全 在过程.函数.事件内部, SHIFT+CTRL+向上的方向键 可跳跃到相应的过程.函数.事件的定义.相反,在过程.函数.事件的定义处,SHIFT+CTRL+向下的方向键 可跳跃 ...