Codeforces Round #556 (Div. 2)-ABC(这次的题前三题真心水)
A. Stock Arbitraging
直接上代码:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<cmath> const int maxn=1e5+;
typedef long long ll;
using namespace std; int main()
{ int n,m,r;
cin>>n>>m>>r;
int x;
int minn=0x3f3f3f3f;
for(int t=;t<n;t++)
{
scanf("%d",&x);
minn=min(minn,x);
}
int maxnn=;
for(int t=;t<m;t++)
{
scanf("%d",&x);
maxnn=max(maxnn,x);
}
if(maxnn<=minn)
{
cout<<r<<endl;
}
else
{
int k=r;
r=r%minn;
r+=(maxnn)*(k/minn);
cout<<r<<endl;
} return ;
}
B. Tiling Challenge
找一下就行了
代码:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<cmath> const int maxn=1e5+;
typedef long long ll;
using namespace std;
char Map[][];
int n;
int dir[][]={{,},{,-},{-,},{,}};
bool check(int x,int y)
{
if(x>=&&x<n&&y>=&&y<n)
{
return true;
}
else
{
return false;
}
}
int main()
{ cin>>n;
getchar();
for(int t=;t<n;t++)
{
scanf("%s",Map[t]);
}
for(int t=;t<n;t++)
{
for(int j=;j<n;j++)
{
int sum=;
if(Map[t][j]=='.')
{
for(int k=;k<;k++)
{
int xx=t+dir[k][];
int yy=j+dir[k][];
//cout<<xx<<" "<<yy<<endl;
if(check(xx,yy)&&Map[xx][yy]=='.')
{
sum++;
}
}
}
if(sum==)
{
Map[t][j]='#';
for(int k=;k<;k++)
{
int xx=t+dir[k][];
int yy=j+dir[k][];
Map[xx][yy]='#';
}
}
}
}
bool flag=true;
for(int t=;t<n;t++)
{
for(int j=;j<n;j++)
{
if(Map[t][j]=='.')
{
flag=false;
}
}
}
if(flag)
{
cout<<"YES"<<endl;
}
else
{
cout<<"NO"<<endl;
}
return ;
}
C. Prefix Sum Primes
思维+构造也很好想
代码;
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<cmath> const int maxn=1e5+;
typedef long long ll;
using namespace std;
vector<int>v1,v2;
int main()
{
int n;
cin>>n;
int x;
for(int t=;t<n;t++)
{
scanf("%d",&x);
if(x==)
v1.push_back(x);
else
{
v2.push_back(x);
}
} if(v1.size()==n)
{
vector<int>::iterator it=v1.begin();
for(it=v1.begin();it!=v1.end();it++)
{
cout<<*it<<" ";
}
}
else if(v2.size()==n)
{
vector<int>::iterator it=v2.begin();
for(it=v2.begin();it!=v2.end();it++)
{
cout<<*it<<" ";
}
}
else
{
cout<<"2 1 ";
int xx=v1.size()-;
int yy=v2.size()-;
for(int t=;t<yy;t++)
{
cout<<"2 ";
}
for(int j=;j<xx;j++)
{
cout<<"1 ";
} }
return ;
}
Codeforces Round #556 (Div. 2)-ABC(这次的题前三题真心水)的更多相关文章
- Codeforces Round #556 (Div. 2) - C. Prefix Sum Primes(思维)
Problem Codeforces Round #556 (Div. 2) - D. Three Religions Time Limit: 1000 mSec Problem Descripti ...
- Codeforces Round #556 (Div. 2) - D. Three Religions(动态规划)
Problem Codeforces Round #556 (Div. 2) - D. Three Religions Time Limit: 3000 mSec Problem Descripti ...
- Codeforces Round #556 (Div. 1)
Codeforces Round #556 (Div. 1) A. Prefix Sum Primes 给你一堆1,2,你可以任意排序,要求你输出的数列的前缀和中质数个数最大. 发现只有\(2\)是偶 ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #247 (Div. 2) ABC
Codeforces Round #247 (Div. 2) http://codeforces.com/contest/431 代码均已投放:https://github.com/illuz/Wa ...
- Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)
Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...
- Codeforces Round #556 (Div. 2)
比赛链接 A 贪心 #include <cstdlib> #include <cstdio> #include <algorithm> #include <c ...
- Codeforces Round #313 (Div. 2) ABC
A http://codeforces.com/contest/560/problem/A 推断给出的数能否组成全部自然数. 水题 int a[1010]; bool b[1000010]; int ...
- Codeforces Round #556 (Div. 2) D. Three Religions 题解 动态规划
题目链接:http://codeforces.com/contest/1150/problem/D 题目大意: 你有一个参考串 s 和三个装载字符串的容器 vec[0..2] ,然后还有 q 次操作, ...
随机推荐
- Win10正式版怎么关闭windows defender
分步阅读 如何关闭Win10正式版系统所自带的"Windows Defender"程序呢?"Windows Defender"程序是Win10正式版系统所自带的 ...
- Java程序设计——对象序列化
对象序列化的目标是将对象保存到磁盘中或允许在网络中直接传输对象,对象序列化机制允许把内存中的Java对象转换成平台无关的二进制流,从而允许把这种二进制流持久保存在磁盘上,通过网络将这种二进制流传输到另 ...
- dns记录类型(转)
NS:(Domain Name System,域名系统),因特网上作为域名和IP地址相互映射的一个分布式数据库,能够使用户更方便的访问互联网,而不用去记住能够被机器直接读取的IP数串.通过主机名,最终 ...
- CodeForces 688B Lovely Palindromes (水题回文)
题意:给一个数n,让你找出长度为偶数,并且是第 n 个回文数. 析:你多写几个就知道了,其实就是 n,然后再加上n的逆序,不过n有点大,直接用string 好了. 代码如下: #include < ...
- 深入解析String#intern
转自:https://tech.meituan.com/in_depth_understanding_string_intern.html 深入解析String#intern john_yang ·2 ...
- tomcat下manager配置
1 安装Tomcat前需要先安装JDK.安装Tomcat后测试Tomcat成功安装. Tomcat Manager是Tomcat自带的.用于对Tomcat自身以及部署在Tomcat上的应用进行管理的w ...
- [label][IDE] Develop Node.js Project With WebStorm
WebStorm 是一个支持 Node.js,CoffeeScript, TypeScript, Dart, Jade, Sass, LESS and Stylus 这些最新 web 开发技术的集成开 ...
- java程序练习
数组求和作业 开发环境:java 工具:eclipse 两种数据类型excel和csv 在同学建议下,我选择用csv文件打开,这就引来了第一个问题,在java中如何调用csv文件.以下是我百度的结果 ...
- web项目开发最佳做法
一个成熟的web项目应该具备以下基础代码或做法 1.前端基础框架: 统一的ajax 通信/表单提交及调用结果弹窗显示 统一的数据验证 统一的数据列表 2.后端基础框架: 统一的异常处理捕获,可针对具体 ...
- Dom4j的一个小例子,用于解析xml文件的元素获取方式(转)
import java.io.File; import java.io.IOException; import javax.xml.parsers.ParserConfigurationExcepti ...