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,大数据命 ...
随机推荐
- Unity关闭shader中的光照模型以及如何自定义光照模型
// Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject' // Upgrade NOTE: replaced '_Wor ...
- FPGA连接
别人推荐,暂时存这了: http://www.eepw.com.cn/news/fpga
- [SublimeText] Sublime Text 2 运行 Python 脚本中文路径解决方法
在 SublimeText 中直接运行 Python 脚本,出现以下报错提示: Running python -u C:\Documents and Settings\Administrator\桌面 ...
- 更新npm至最新版本
npm install npm@latest –g 或者@ 符号后面直接添加你想更新到的版本号
- React Native(四)——顶部以及底部导航栏实现方式
效果图: 一步一步慢慢来: 其实刚入手做app的时候,就应该做出简单的顶部以及底部导航栏.无奈又在忙其他事情,导致这些现在才整理出来. 1.顶部导航栏:react-native-scrollable- ...
- mysql的存储过程与事务入门
存储过程是:通过一系列的SQL语句, 根据传入的参数(也可以没有), 通过简单的调用, 完成比单个SQL语句更复杂的功能, 存储在数据库服务器端,只需要编译过一次之后再次使用都不需要再进行编译.主要对 ...
- Struts2(一)基本配置
一.Struts2概述 1.什么是Struts2? Struts2以WebWork为核心,采用拦截器的机制来处理用户的请求,这样使得业务逻辑控制器能够和ServletAPI脱离开来. 2.工作原理 当 ...
- php 建立 搜索 分词树
<?php /** * @author: xiaojiang 20140107 * php 建立分词树 * */ class Tree{ public $w = ''; public $subT ...
- HTML-锚点-JS跳转锚点
window.location.hash使用说明,这篇写的挺详细的 http://www.cnblogs.com/nifengs/p/5104763.html a标签的话是 name,div呢是id, ...
- Material Design系列第三篇——Using the Material Theme
Using the Material Theme This lesson teaches you to Customize the Color Palette Customize the Status ...