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 ...
随机推荐
- 线特征---LSD and LBD程序运行(一)
最近在看有关特征提取的线特征,暑期就看了相关的论文:<基于点线综合特征的双目视觉SLAM方法_谢晓佳>,最近呢,把里面有关线特征提取LSD和描述子LBD的代码跑了一遍,记录如下: [1]L ...
- VML、SVG、Canvas简介
1.VML: VML的全称是Vector Markup Language(矢量可标记语言),矢量的图形,意味着图形可以任意放大缩小而不损失图形的质量,这在制作地图上有很大用途,VML只是被IE支持. ...
- React-router4 笔记
第一次看React-router发现根据阮一峰老师教程老报错,,完全一样的代码还是报错,,然而到最后才发现自己安装的版本太高了! 由于菜鸟比较新,npm install react-router 这样 ...
- linux 管道符与通配符
###管道符 *命令格: 命令1 | 命令2 //命令1的正确输出作为命令2的操作对象 ll | more netstat -an | grep xxx 通配符 类似于正则表达式 ? 一个以上 [] ...
- Android开发之SharedPreferences的封装
对于大部分初学者来说,如果想利用SharedPreferences进行数据存储的话大部分人(包括本人)应该会这样: 存储: SharedPreferences sharedPreferences = ...
- PYthon end
关键字end可以用于将结果输出到同一行,或者在输出的末尾添加不同的字符. # -*- coding:utf-8 -*- count = 1 while count <=5: i=1 while ...
- Kali Linux 网络扫描秘籍
第三章 端口扫描(二) 作者:Justin Hutchens 译者:飞龙 协议:CC BY-NC-SA 4.0 3.6 Scapy 隐秘扫描 执行 TCP 端口扫描的一种方式就是执行一部分.目标端口上 ...
- .net序列化
在开发过程中,会遇到很多需要使用序列化的场景,比如wcf,webservice或者jquery+.net等.那今天就说说我对序列化的理解. 在.net中有几种序列化的方式,XML.二进制.SOAP.还 ...
- Codeforces 803C. Maximal GCD 二分
C. Maximal GCD time limit per test: 1 second memory limit per test: 256 megabytes input: standard in ...
- DIOCP组件(Delphi IOCP)代码阅读之ADO内存表
DIOCP组件(Delphi IOCP)代码阅读之ADO内存表 代码中有 class procedure TADOTools.loadFromStream(pvDataSet: TCustomADOD ...