Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2)
A. Search for Pretty Integers
题目链接:http://codeforces.com/contest/872/problem/A
题目意思:题目很简单,找到一个数,组成这个数的数字即在A数组中出现过,也在B数组中出现过,问这个数最小是多少。
题目思路:首先要么一个数两个数组都出现过直接输出来,要么分别取两个数组中最小的数组合一下输出。
代码:
//Author: xiaowuga
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define MAX INT_MAX
#define mem(s,ch) memset(s,ch,sizeof(s))
const long long N=;
const long long mod=1e9+;
typedef long long LL;
typedef int II;
typedef unsigned long long ull;
#define nc cout<<"nc"<<endl
#define endl "\n"
int main() {
ios::sync_with_stdio(false);cin.tie();
int a=,b=;
int n,m;
int aa[]={},bb[]={};
cin>>n>>m;
for(int i=;i<n;i++){
int t;
cin>>t;
a=min(a,t);
aa[t]=;
}
for(int i=;i<m;i++){
int t;
cin>>t;
b=min(b,t);
bb[t]=;
}
for(int i=;i<=;i++){
if(aa[i]&&bb[i]){
cout<<i<<endl;
return ;
}
}
if(a>b) swap(a,b);
cout<<(a*)+b<<endl;
return ;
}
B. Maximum of Maximums of Minimums
题目链接:http://codeforces.com/contest/872/problem/B
题目意思:一个数列有n个数,现在把他分成k份,要让k份中每一份中的最小值的最大值最大。
题目思路:当k=1的时候,答案必定是数列的最小值,当k>2的时候,答案必定是数列的最大值。当k=2的时候但是必定是数列第一项和最后一项中最大值。
代码:
//Author: xiaowuga
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define MAX INT_MAX
#define mem(s,ch) memset(s,ch,sizeof(s))
const long long N=;
const long long mod=1e9+;
typedef long long LL;
typedef int II;
typedef unsigned long long ull;
#define nc cout<<"nc"<<endl
#define endl "\n"
int main() {
ios::sync_with_stdio(false);cin.tie();
long long a[+];
int n,k;
cin>>n>>k;
long long mi=inf,ma=-inf;
for(int i=;i<n;i++){
cin>>a[i];
mi=min(mi,a[i]);
ma=max(ma,a[i]);
}
if(k==) cout<<mi<<endl;
else if(k>) cout<<ma<<endl;
else {
cout<<max(a[],a[n-])<<endl;
}
return ;
}
C. Maximum splitting
题目链接:http://codeforces.com/contest/872/problem/C
题目意思:给出一个数,可以分成多少个合数的和。
题目思路:首先最小的合数是4,所以根据贪心的思路就是尽量分出4来。直接代码吧
代码:
//Author: xiaowuga
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define MAX INT_MAX
#define mem(s,ch) memset(s,ch,sizeof(s))
const long long N=;
const long long mod=1e9+;
typedef long long LL;
typedef int II;
typedef unsigned long long ull;
#define nc cout<<"nc"<<endl
#define endl "\n"
int main() {
ios::sync_with_stdio(false);cin.tie();
int q;
long long k;
cin>>q;
while(q--){
cin>>k;
long long x=k/;
if(k%==) cout<<x<<endl;
else if(k%==){
if(x->=){
cout<<x-<<endl;
}
else cout<<-<<endl;
}
else if(k%==){
if(x->=){
cout<<x<<endl;
}
else cout<<-<<endl;
}
else if(k%==){
if(x->=){
cout<<x-<<endl;
}
else cout<<-<<endl;
}
}
return ;
}
Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2)的更多相关文章
- Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2) D. Something with XOR Queries
地址:http://codeforces.com/contest/872/problem/D 题目: D. Something with XOR Queries time limit per test ...
- Codeforces Round #440 (Div. 1, based on Technocup 2018 Elimination Round 2) C - Points, Lines and Ready-made Titles
C - Points, Lines and Ready-made Titles 把行列看成是图上的点, 一个点(x, y)就相当于x行 向 y列建立一条边, 我们能得出如果一个联通块是一棵树方案数是2 ...
- Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2) C. Maximum splitting
地址: 题目: C. Maximum splitting time limit per test 2 seconds memory limit per test 256 megabytes input ...
- ACM-ICPC (10/15) Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2)
A. Search for Pretty Integers You are given two lists of non-zero digits. Let's call an integer pret ...
- Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861C Did you mean...【字符串枚举,暴力】
C. Did you mean... time limit per test:1 second memory limit per test:256 megabytes input:standard i ...
- Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861B Which floor?【枚举,暴力】
B. Which floor? time limit per test:1 second memory limit per test:256 megabytes input:standard inpu ...
- Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861A k-rounding【暴力】
A. k-rounding time limit per test:1 second memory limit per test:256 megabytes input:standard input ...
- Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)
A. k-rounding 题目意思:给两个数n和m,现在让你输出一个数ans,ans是n倍数且末尾要有m个0; 题目思路:我们知道一个数末尾0的个数和其质因数中2的数量和5的数量的最小值有关系,所以 ...
- 【模拟】 Codeforces Round #434 (Div. 1, based on Technocup 2018 Elimination Round 1) C. Tests Renumeration
题意:有一堆数据,某些是样例数据(假设X个),某些是大数据(假设Y个),但这些数据文件的命名非常混乱.要你给它们一个一个地重命名,保证任意时刻没有重名文件的前提之下,使得样例数据命名为1~X,大数据命 ...
随机推荐
- ios开发之--WKWebView的使用
WKWebView是ios 8 出来的,是为了解决UIWebView卡慢,占用内存过大的问题. 在以往时候,如果用UIWebView加载加载网页的时候,卡慢现象会很严重,有时候往往会卡到一个页面无法动 ...
- python中安装dlib和cv2
这两个模块是很容易出问题的模块,以下的解决办法都是从网上收集而来. 安装dlib: pypi.python.org/pypi/dlib/19.6.0 下载 dlib-19.6.0-cp36-cp36m ...
- Oracle sqlldr导入之“MAXIMUM ERROR COUNT EXCEEDED”
昨天看到一个同事在通过PL/SQL Developer工具把文本数据往oracle表;有两个文本:一个有30万条记录:一个7万多条记录.在导入到过程中:出现错误记录还需要点击确认.不过使用黑科技(屏幕 ...
- 【PHP代码审计】 那些年我们一起挖掘SQL注入 - 1.什么都没过滤的入门情况
0x01 背景 首先恭喜Seay法师的力作<代码审计:企业级web代码安全架构>,读了两天后深有感触.想了想自己也做审计有2年了,决定写个PHP代码审计实例教程的系列,希望能够帮助到新人更 ...
- Cookie利用神器:CookieHacker
转自evilcos的博客 看到那么多苦逼的跨站师在问Cookie利用工具,不忍心,还是把自己写的Chrome扩展开源出来吧,功能极简,仿造<我的渗透利器>里提到的Original Cook ...
- 天猫浏览型应用的CDN静态化架构演变(转)
转自:http://wbj0110.iteye.com/blog/2036613 在天猫双11活动中,商品详情.店铺等浏览型系统,通常会承受超出日常数倍甚至数十倍的流量冲击.随着历年来双11流量的大幅 ...
- Java的Integer和int有什么区别
Java是面向对象的编程语言,一切都是对象,但是为了编程的方便还是引入了基本数据类型,为了能够将这些基本数据类型当成对象操作,Java为每一个基本数据类型都引入了对应的包装类型(wrapper cla ...
- 【Java知识点专项练习】之 接口和抽象类的区别
接口和抽象类的区别 接口(interface)可以说成是抽象类的一种特例,接口中的所有方法都必须是抽象的.接口中的方法定义默认为public abstract类型,接口中的成员变量类型默认为publi ...
- Glide加载图片缓存库出现——You cannot start a load for a destroyed activity
请记住一句话:不要再非主线程里面使用Glide加载图片,如果真的使用了,请把context参数换成getApplicationContext.
- cxGrid数据录入
一.数据录入 1 在TcxGridDBTableView中,设定属性 NewItemRow.Visible = True 2 在cxgrid中输入数据怎样回车换行 在TcxGridDBTableV ...