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. dedecms实例化对象

    1.建表 2.创建实体类 4.tc文件加载该实体类 5.用的时候,引入tc.php文件,并实例化

  2. Jenkins 邮箱配置及问题解决

    Failed to send out e-mail javax.mail.MessagingException: Could not connect to SMTP host: smtp.rytong ...

  3. POJ 2778 DNA Sequence (AC自动机+DP+矩阵)

    题意:给定一些串,然后让你构造出一个长度为 m 的串,并且不包含以上串,问你有多少个. 析:很明显,如果 m 小的话 ,直接可以用DP来解决,但是 m 太大了,我们可以认为是在AC自动机图中,根据离散 ...

  4. ldap域账号登录

    $host = "iflytek.com"; $user = 'yimiao@'.$host;//'用户名@域名'; $pswd = "******"; //1 ...

  5. java文件的读写程序代码

    package textopen; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutp ...

  6. ios中改变UIImagePickerController页面的button的文字为中文

    可以在工程中直接 project-->info-->Localization native development region   赋值为 zh_CN

  7. 开通博客暨注册github事件

    (1) 姓      名:丁新宇 学      号:1413042054 班      级:网工142 兴趣爱好:听歌.看书.编代码. (2) GitHub注册流程: 1,百度搜索GitHub,进入官 ...

  8. .Net Core下使用Ajax,并传送参数到controllers

    可以使用URL拼接方式方法传参 .cshtml部分 @section Scripts{ @{ await Html.RenderPartialAsync("_ValidationScript ...

  9. cesium编程入门(五)绘制形状

    通过Entity添加形状 先来看一个添加立方体的例子 var viewer = new Cesium.Viewer('cesiumContainer'); var redBox = **viewer. ...

  10. 为什么JavaScript要有null?(翻译)

    原文地址 JavaScript有不少怪癖和难以理解的地方.其中null& undefined就比较有意思.既然有了为什么JavaScript还要弄一个null? 相等比较 让我们开始由具有看看 ...