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 ...
随机推荐
- RxJava笔记
网上搜索了一些关于 RxJava 的东西,对RxJava的定义自己理解如下: RxJava是要一种逻辑简洁的,通过一种扩展的观察者模式,来实现异步的一种链式编程.
- (转)easyui datagrid 部分参数说明
easyui datagrid 部分参数 数据表格属性(DataGrid Properties) 属性继承控制面板,以下是数据表格独有的属性. 名称 类型 描述 默认值 columns array 数 ...
- tmux 快捷操作
-- 基本使用 tmux # 运行 tmux -2 以256终端运行 C-b d # 返回主 shell , tmux 依旧在后台运行,里面的命令也保持运行状态 tmux ls # 显示已有tm ...
- LibreOJ 6003. 「网络流 24 题」魔术球 贪心或者最小路径覆盖
6003. 「网络流 24 题」魔术球 内存限制:256 MiB时间限制:1000 ms标准输入输出 题目类型:传统评测方式:Special Judge 上传者: 匿名 提交提交记录统计讨论测试数据 ...
- delphi新手到高手的工具--castalia
castalia翻译是 神泉 ,是delphi的一个优秀第三方工具.其重构功能尤为突出.代码实时编译提示也很棒. 自卑delphi开发工具没有eclipse那么强大的提示?有castalia为你提升信 ...
- ubuntu 下通过ftp命令下载文件
/*连接*/ $ ftp 192.168.180.2Connected to 192.168.180.2.Name (192.168.180.2:rivsidn): admin Password: ...
- Servlet 2.x 规范
Servlet 2.x 规范 sun 公司制订的一种基于 Java 技术的 WEB 服务器功能的组件规范.1997 年六月,Servlet 1.0 版本发行,最新版本 Servlet 4.0 处于研发 ...
- 补课:Shell命令${}
Shell中的${}.##和%%使用范例: 代码如下:file=/dir1/dir2/dir3/my.file.txt可以用${ }分别替换得到不同的值:${file#*/}:删掉第一个 / 及其左边 ...
- mysql mariadb的VC客户端遇到的问题
在使用VS2017编写数据库客户端 具体设置可参见以下内容 https://dev.mysql.com/doc/connector-cpp/en/connector-cpp-apps-windows- ...
- How to Create Triggers in MySQL
https://www.sitepoint.com/how-to-create-mysql-triggers/ I created two tables: CREATE TABLE `sw_user` ...