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(这次的题前三题真心水)的更多相关文章

  1. Codeforces Round #556 (Div. 2) - C. Prefix Sum Primes(思维)

    Problem  Codeforces Round #556 (Div. 2) - D. Three Religions Time Limit: 1000 mSec Problem Descripti ...

  2. Codeforces Round #556 (Div. 2) - D. Three Religions(动态规划)

    Problem  Codeforces Round #556 (Div. 2) - D. Three Religions Time Limit: 3000 mSec Problem Descripti ...

  3. Codeforces Round #556 (Div. 1)

    Codeforces Round #556 (Div. 1) A. Prefix Sum Primes 给你一堆1,2,你可以任意排序,要求你输出的数列的前缀和中质数个数最大. 发现只有\(2\)是偶 ...

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

  5. Codeforces Round #247 (Div. 2) ABC

    Codeforces Round #247 (Div. 2) http://codeforces.com/contest/431  代码均已投放:https://github.com/illuz/Wa ...

  6. Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)

    Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...

  7. Codeforces Round #556 (Div. 2)

    比赛链接 A 贪心 #include <cstdlib> #include <cstdio> #include <algorithm> #include <c ...

  8. Codeforces Round #313 (Div. 2) ABC

    A http://codeforces.com/contest/560/problem/A 推断给出的数能否组成全部自然数. 水题 int a[1010]; bool b[1000010]; int ...

  9. Codeforces Round #556 (Div. 2) D. Three Religions 题解 动态规划

    题目链接:http://codeforces.com/contest/1150/problem/D 题目大意: 你有一个参考串 s 和三个装载字符串的容器 vec[0..2] ,然后还有 q 次操作, ...

随机推荐

  1. Redis 安装配制

    Redis 安装配制 redis 安装分为单机安装.伪集群安装.集群安装. Redis 下载地址:http://www.redis.cn/download.html Redis 在线测试工具:http ...

  2. IntelliJ IDEA 2017版 导入maven项目需要的包

    1.选中项目,鼠标右键--->maven---->Reimport

  3. java内存溢出异常

    名称 特征 作用 配置参数 异常 程序 计数器 占用内存小,线程私有, 生命周期与线程相同 大致为字节码行号指示器 无 无 虚拟机栈 线程私有,生命周期与线程 相同,使用连续的内存空间 Java 方法 ...

  4. JVM GC 机制与性能优化

    目录(?)[+] 1 背景介绍 与C/C++相比,JAVA并不要求我们去人为编写代码进行内存回收和垃圾清理.JAVA提供了垃圾回收器(garbage collector)来自动检测对象的作用域),可自 ...

  5. 更改mysql默认字符集 (转载)

    1. service mysqld stop,停用mysql. 2. cp /etc/my.cnf /etc/my.cnf.bak,修改前做备份,这是个好习惯. 修改my.cnfvi /etc/my. ...

  6. nmon在secureCRT下显示乱码问题

    # 背景 下载安装了nmon,结果发现显示有问题,如下 # 解决 猜测应该是字体编码问题,查阅了解后,是因为CRT设置问题,需要修改下配置,(之前试用xshell比较棒,但公司禁止试用),如下修改 然 ...

  7. sql trace script

    CREATE EVENT SESSION [sql_query_tracing] ON SERVER ADD EVENT sqlos.wait_info(    ACTION(sqlos.schedu ...

  8. 如何让你的项目同时支持go vendor和go module

    目录 如何让你的项目同时支持go vendor和go module 1. go module简介 2. 使用go mod命令管理项目 2.1 初始化环境 2.2 构建 3. 保持兼容性 4. 使用go ...

  9. linux 配置msyql

    下面记录了如何在ubuntu16.04上安装mysql5.7的方法. sudo apt install mysql-server 安装时会让你输入mysql root用户的密码,并确认密码 sudo ...

  10. Aircrack-ng无线破解总结

    过年回来家,奈何没网,实属无奈,只好看破解教程,看能否破出来.于是总结如下 测试环境在linux平台下,我用的是ubuntu环境.ubuntu安装可以直接用sudo apt-get install a ...