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. linux网络编程模型

    1.编程模型 Linux网络编程模型是基于socket的编程模型

  2. SLAM拾萃(2):doxygen

    今天给大家介绍一下doxygen.这个工具由来已久了,至少08年左右就已经在用了,但是目前还没见到好的介绍.我个人觉得这是个很简单易用的工具,但是为什么看了别人介绍反而觉得复杂了……所以趁着今天比较闲 ...

  3. GCT英语口语复试中的常见问题总汇

    英语口语复试中常见的问题: 1. Where do you come from? 2. What kind of landscape surrounds your hometown? 3. What ...

  4. Introduction to Razor Pages in ASP.NET Core

    https://docs.microsoft.com/en-us/aspnet/core/mvc/razor-pages/ 从ASP.NET Core 2.0.0版本之后,添加了新的特性Razor p ...

  5. UVaLive 4128 Steam Roller (多决策最短路)

    题意:给定一个图,r 根横线, c 根竖线.告诉你起点和终点,然后从起点走,每条边有权值,如果是0,就表示无法通行.走的规则是:如果你在下个路要转弯,会使这段路的时间加倍,但是如果一条路同时是这样,那 ...

  6. [转]构建基于WCF Restful Service的服务

    本文转自:http://www.cnblogs.com/scy251147/p/3566638.html 前言 传统的Asmx服务,由于遵循SOAP协议,所以返回内容以xml方式组织.并且客户端需要添 ...

  7. (轉)CSS 单行溢出文本显示省略号...的方法(兼容IE FF)

    轉自:http://www.cnblogs.com/hlz789456123/archive/2009/02/18/1392972.html html代码:<div><p>&l ...

  8. Excel2010画动态甘特图

    哈哈!你居然真的看简介点进来啦,我也想八一八Henry gantt本人的故事,可是我查了好些资料,一个槽点都没有发现,不过人生经历还是蛮拼的: 此人活了58年,前半生就是一个中规中距的机械工程师&am ...

  9. .net读写xml

    XML文件 <?xml version="1.0" encoding="utf-8"?> <book> <title>web ...

  10. WPF 新手引导

    参考了https://www.cnblogs.com/ZXdeveloper/p/8391864.html,自己随便实现了一个,记录下,比较丑 <Window x:Class="Use ...