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 ...
随机推荐
- 简述 OAuth 2.0 的运作流程(转)
原文地址:http://www.barretlee.com/blog/2016/01/10/oauth2-introduce/ 本文将以用户使用 github 登录网站留言为例,简述 OAuth 2. ...
- HR 常用事务代码
HR的键值权限查看: oosb 删除人员 : pu01 查看人员主数据:PA30 对人员进行入职.离职.调岗等基本操作:PA40 查看HR中的公式的意思:PE04 查看HR中的工资项:PE02 创建 ...
- 关于EOF:
请先看下面一段程序: #include"stdio.h" int main() { ],t; int i,j; while(scanf("%s",a)!=EOF ...
- 在threejs中对3D物体旋转的思考
今天在写threejs时,突然想到一个问题:一个3D物体需要旋转时,一般情况下简单的旋转我都是使用欧拉角,稍微复杂一些的情况我会把欧拉角转换成四元数进行旋转(欧拉角复杂旋转可能会产生的死锁问题),但是 ...
- vs的【warning C4996:'fopen': This function or variable may be unsafe】解决方案
编译警告:warning C4996 与 Security Enhancements in the CRT 将过去的工程用VS2005打开的时候.你有可能会遇到一大堆的警告:warning C4996 ...
- 利用spring boot构建一个简单的web工程
1.选择Spring InitiaLizr, jdk选择好路径 2.设置项目信息 3.这一步是设置选择使用哪些组件,这里我们只需要选择web 4.设置工程名和路径
- 去掉easyui datagrid内部虚线的方式。
去掉easyui datagrid内部虚线的方式.easyui datagrid的样式是统一写在样式文件中的,如果想要统一替换可以找对应的datagird样式文件中的以下部分.如果想要改 ...
- dataTables的学习笔记 -- 未开启服务器数据模式
官方网站:http://www.datatables.net/ (1)未开启服务器数据模式(即"bServerSide" : false),数据会从后台直接全部获取,然后在前台全部 ...
- Python.tornado.2.tornado.options
记录Tornado-4.0.2源码的阅读,学习,分析 options.py 1. imports 部分 1.1 __future__ from __future__ import absolute_i ...
- js 中 的 if使用条件
在javascript中,哪些值能作为if的条件呢 1.布尔变量true/false2.数字非0,非NaN/ (0 或NaN) 见下面的例子,莫以为负数就以为if语句为假了. 复制代码代码如下: va ...