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)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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的数量的最小值有关系,所以 ...

  9. 【模拟】 Codeforces Round #434 (Div. 1, based on Technocup 2018 Elimination Round 1) C. Tests Renumeration

    题意:有一堆数据,某些是样例数据(假设X个),某些是大数据(假设Y个),但这些数据文件的命名非常混乱.要你给它们一个一个地重命名,保证任意时刻没有重名文件的前提之下,使得样例数据命名为1~X,大数据命 ...

随机推荐

  1. Java -- 异常的捕获及处理 -- throws与throw关键字

    7.2 throws 与 throw关键字 7.2.1 throws 关键字 在定义一个方法时可以使用throws关键字声明,使用throws声明的方法标识此方法不处理异常,而交给方法的调用处进行处理 ...

  2. Dubbo -- 系统学习 笔记 -- 成熟度

    Dubbo -- 系统学习 笔记 -- 目录 成熟度 功能成熟度 策略成熟度 啦啦啦

  3. VC++6.0相对路径无效的解决办法

    我们在开发程序时,常常需要操作相关的文件.操作文件一般有两种方法:绝对路径和相对路径.绝对路径是从盘符开始的,相对路径则是相对于当前目录. 绝对路径很简单,一般也不会出错,但是在实际开发过程中要慎用绝 ...

  4. GSAP JS基础教程--使用缓动函数

    今天来了解一下缓动easeing函数. 开始,如果你还没有GSAP的类包,可以到GreenSock的官网去下载最新版本的类包,或者直接点击这里​来下载 学习之前,先来准备一下:     <!DO ...

  5. Nginx(十一)-- keepalived简介

    1. 什么是keepalived 基于VRRP(虚拟路由器冗余协议)来实现对web服务的高可用方案. keepalived下载地址:http://download.csdn.net/detail/u0 ...

  6. CentOS7--使用yum安装和管理软件

    yum是红帽软件包管理器,它能能够查询,安装和卸载软件包,以及将整个系统更新到最新的可用版本.Yum可以在安装的过程中自动解决依赖关系. 1. 检查和更新软件包 1.1 查询更新 查看系统上哪些已安装 ...

  7. code_blocks 使用操作手册

                                                                              38 39 编译以上程序,产生如下提示信息. 如此简 ...

  8. 安装ubuntu后,你的屏幕尺寸太小,无法设置,该怎么解决

    安装完虚拟机之后,你的Ubuntu可能会在尺寸很小,(这种情况可能有,可能没有) 想要点击设置,选中Display里的分辨率下拉框,但是却因为这个窗口太大,无法点击apply按钮.悲剧啦!!! Ctr ...

  9. C++标准程序库笔记之一

    本篇博客笔记顺序大体按照<C++标准程序库(第1版)>各章节顺序编排. ---------------------------------------------------------- ...

  10. Servlet基本用法(二)接口和类

    一.摘要 本文主要简单介绍开发Servlet需要用到的接口和类. 二.ServletRequest和ServletResponse接口 当客户请求到来时,由容器创建一个ServletRequest对象 ...