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. html5页面平滑切换实现以及问题(20160120更新)

    注:本文是基于手机端 Hybrid APP 讨论,而不是普通的PC端网页 >> 之前的页面跳转方式: 比如有这两个页面:A.html  B.html,  A B 是纯HTML实现,没有采用 ...

  2. 8 -- 深入使用Spring -- 1...2 Bean后处理器的用处

    8.1.2 Bean后处理器的用处 Spring提供的两个常用的后处理器: ⊙ BeanNameAutoProxyCreator : 根据Bean实例的name属性,创建Bean实例的代理. ⊙ De ...

  3. Linux-selinux

    查看SELinux状态: 1./usr/sbin/sestatus -v      ##如果SELinux status参数为enabled即为开启状态 SELinux status:         ...

  4. Excel导出到浏览器(个人备份)

    /// <summary>  /// Excel导出  /// </summary>  /// <param name="dt"></pa ...

  5. mac 常用的终端命令

    OSX 的文件系统 OSX 采用的Unix文件系统,所有文件都挂在跟目录 / 下面,所以不在要有Windows 下的盘符概念. 你在桌面上看到的硬盘都挂在 /Volumes 下. 比如接上个叫做 US ...

  6. thinkphp3.2 实现留言功能

    写一个例子说明一下: 前端:http://www.mmkb.com/zhendao/index/feedback.html <form method="post" actio ...

  7. 【NET多线程】C#多线程异步请求多个url地址

    异步测试代码 System.Diagnostics.Debug.Print("start"); new Thread(new ThreadStart(new Action(() = ...

  8. 【ipad神坑】ipad麦克风听不到声音怎么回事 微信QQ语音视频对方都听不到

    今天遇到了这个问题 说话听不见,但是敲击ipad,可以明显的听到击打的声音 siri也是可以听到 上网上找,大多都是说恢复设置,重启,隐私麦克风权限等解决方案 都是浪费感情 全部尝试过了,依然没有用. ...

  9. python框架---->BeautifulSoup的使用

    Beautiful Soup 是一个可以从HTML或XML文件中提取数据的Python库.它能够通过你喜欢的转换器实现惯用的文档导航,查找,修改文档的方式.一个人至少拥有一个梦想,有一个理由去坚强.心 ...

  10. 云计算设计模式(六)——命令和查询职责分离(CQRS)模式

    云计算设计模式(六)——命令和查询职责分离(CQRS)模式 隔离,通过使用不同的接口,从操作读取数据更新数据的操作.这种模式可以最大限度地提高性能,可扩展性和安全性;支持系统在通过较高的灵活性,时间的 ...