AtCoder Beginner Contest-060
A - Shiritori
Problem Statement
You are given three strings A, B and C. Check whether they form a word chain.
More formally, determine whether both of the following are true:
The last character in A and the initial character in B are the same.
The last character in B and the initial character in C are the same.
If both are true, print YES. Otherwise, print NO.
Constraints
A, B and C are all composed of lowercase English letters (a - z).
1≤|A|,|B|,|C|≤10, where |A|, |B| and |C| are the lengths of A, B and C, respectively.
题目大意
给三个字符串,ABC是否首位相接
代码
#include <bits/stdc++.h>
using namespace std;
string a,b,c;
int main()
{
cin>>a>>b>>c;
if (a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
B - Choose Integers
Problem Statement
We ask you to select some number of positive integers, and calculate the sum of them.
It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.
Your objective is to make the sum congruent to C modulo B. Determine whether this is possible.
If the objective is achievable, print YES. Otherwise, print NO.
题目大意
(k*a)%b是否有c这个余数
代码
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int f[100];
int main()
{
cin>>a>>b>>c;
int j=a%b;
while (1)
{
if (j==c)
{
cout<<"YES"<<endl;
return 0;
}
if (f[j])
{
cout<<"NO"<<endl;
return 0;
}else f[j]=1;
j=(j+a)%b;
}
}
C - Sentou
Problem Statement
In a public bath, there is a shower which emits water for T seconds when the switch is pushed.
If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds.
N people will push the switch while passing by the shower. The i-th person will push the switch ti seconds after the first person pushes it.
How long will the shower emit water in total?
题目大意
给出一堆线段,问覆盖的长度是多少,升序O(n)扫一遍就好了
代码
#include <bits/stdc++.h>
using namespace std;
int n,t;
int f[200010];
long long ans;
int main()
{
cin>>n>>t;
for (int i=1;i<=n;i++) scanf("%d",&f[i]);
for (int i=1;i<n;i++) ans+=min(f[i+1]-f[i],t);
cout<<ans+t<<endl;
}
D - Simple Knapsack
Problem Statement
You have N items and a bag of strength W. The i-th item has a weight of wi and a value of vi.
You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W.
Your objective is to maximize the total value of the selected items.
Constraints
1≤N≤100
1≤W≤109
1≤wi≤109
For each i=2,3,…,N, w1≤wi≤w1+3.
1≤vi≤107
W, each wi and vi are integers.
题目大意
装包问题,发现有w1≤wi≤w1+3这个条件,就可以压缩背包大小
f[i][j]表示装了i个物品,重量为w1*i+j;
代码
#include <bits/stdc++.h>
using namespace std;
int n;
int w;
long long a[110];//w
long long b[110]; //v
long long f[110][330];
const int INF=(0x7fffffff)/2;
long long ans;
int main()
{
cin>>n>>w;
for (int i=1;i<=n;i++) cin>>a[i]>>b[i];
for (int i=0;i<110;i++)
for (int o=0;o<330;o++) f[i][o]=-INF;
f[0][0]=0;
for (int i=1;i<=n;i++)
for (int o=i-1;o>=0;o--)
for (int j=0;j<=3*o;j++)
if (f[o][j]!=INF) f[o+1][j+(a[i]-a[1])]=max(f[o+1][j+(a[i]-a[1])],f[o][j]+b[i]);
for (int i=1;i<=n;i++)
for (int o=0;o<330;o++) if (i*a[1]+o<=w && f[i][o]!=INF) ans=max(ans,f[i][o]);
cout<<ans<<endl;
}
赛后反思
很简单的题目,难点在于英文阅读qwq。
AtCoder Beginner Contest-060的更多相关文章
- AtCoder Beginner Contest 100 2018/06/16
A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...
- AtCoder Beginner Contest 052
没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...
- AtCoder Beginner Contest 053 ABCD题
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...
- AtCoder Beginner Contest 136
AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...
- AtCoder Beginner Contest 137 F
AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...
- AtCoder Beginner Contest 076
A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...
- AtCoder Beginner Contest 079 D - Wall【Warshall Floyd algorithm】
AtCoder Beginner Contest 079 D - Wall Warshall Floyd 最短路....先枚举 k #include<iostream> #include& ...
- AtCoder Beginner Contest 064 D - Insertion
AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N co ...
- AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle【暴力】
AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle 我要崩溃,当时还以为是需要什么离散化的,原来是暴力,特么五层循环....我自己写怎么都 ...
- AtCoder Beginner Contest 075 C bridge【图论求桥】
AtCoder Beginner Contest 075 C bridge 桥就是指图中这样的边,删除它以后整个图不连通.本题就是求桥个数的裸题. dfn[u]指在dfs中搜索到u节点的次序值,low ...
随机推荐
- java遍历当前会话所有Session
//方法一:通过遍历的方法进行遍历 String FileName=""; HttpSession session=request.getSession();//获取session ...
- ThreadLocal ——android消息机制handler在非主线程创建not called Looper.prepare() 错误的原因
引用自:https://www.jianshu.com/p/a8fa72e708d3 引出: 使用Handler的时候,其必须要跟一个Looper绑定.在UI线程可直接初始化Handler来使用.但是 ...
- Python爬虫项目--爬取自如网房源信息
本次爬取自如网房源信息所用到的知识点: 1. requests get请求 2. lxml解析html 3. Xpath 4. MongoDB存储 正文 1.分析目标站点 1. url: http:/ ...
- ef linq 中判断实体中是否包含某集合
我有一个需求,问题有很多标签,在查询时,需要筛选包含查询标签的一个集合(List<int>),以前的做法是先查询出来符合查询标签条件的标签id的结果集A,再查询问题时,加上判断是否包含该标 ...
- PYthon end
关键字end可以用于将结果输出到同一行,或者在输出的末尾添加不同的字符. # -*- coding:utf-8 -*- count = 1 while count <=5: i=1 while ...
- hdu 1495 (搜索) 非常可乐
http://acm.hdu.edu.cn/showproblem.php?pid=1495 搜索模拟出每此倒得情况就好,详情见代码\ (好困啊!!!!1) #include<cstdio> ...
- eclipse集成svn进行项目开发
在用eclipse进行项目开发的时候,报了一个错误:switch不支持String的参数.这个问题的原因是因为jre版本低于1.7,而当前的eclipse版本最高只能选1.6,无奈,我只能考虑换ecl ...
- robot framework测试驱动无法定位页面元素
robot framework错误提示: [ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: NoSuchW ...
- Ubuntu中文乱码问题解决方案
问题描述 在ubuntu上部署了jar包(java开发的图形界面),但是图形界面上的中文显示乱码. 采用以下步骤后你能够完美支持中文 第一步,安装中文支持包langauge-pack-zh-hans ...
- java mail 读取邮件列表,
// 准备连接服务器的会话信息 Properties props = new Properties(); props.setProperty("mail.store.protocol&quo ...