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的更多相关文章

  1. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

  2. AtCoder Beginner Contest 052

    没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...

  3. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  4. AtCoder Beginner Contest 136

    AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...

  5. AtCoder Beginner Contest 137 F

    AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...

  6. AtCoder Beginner Contest 076

    A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...

  7. AtCoder Beginner Contest 079 D - Wall【Warshall Floyd algorithm】

    AtCoder Beginner Contest 079 D - Wall Warshall Floyd 最短路....先枚举 k #include<iostream> #include& ...

  8. AtCoder Beginner Contest 064 D - Insertion

    AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N co ...

  9. AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle【暴力】

    AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle 我要崩溃,当时还以为是需要什么离散化的,原来是暴力,特么五层循环....我自己写怎么都 ...

  10. AtCoder Beginner Contest 075 C bridge【图论求桥】

    AtCoder Beginner Contest 075 C bridge 桥就是指图中这样的边,删除它以后整个图不连通.本题就是求桥个数的裸题. dfn[u]指在dfs中搜索到u节点的次序值,low ...

随机推荐

  1. 亚像素Sub Pixel

    亚像素Sub Pixel 评估图像处理算法时,通常会考虑是否具有亚像素精度. 亚像素概念的引出: 图像处理过程中,提高检测方法的精度一般有两种方式:一种是提高图像系统的光学放大倍数和CCD相机的分辨率 ...

  2. ES6 Reflect的认识

    首先我们要了解一下,为什么会新添加这么一个全局对象?如果你看过Reflect的一些函数,你就会发现,这个对象上的方法基本上都可以从Object上面找到,找不到的那些,也是可以通过对对象命令式的操作去实 ...

  3. hdu 2444(二分图) The Accomodation of Students

    http://acm.hdu.edu.cn/showproblem.php?pid=2444 大意是给定n个学生,他们之间可能互相认识,首先判断能不能将这些学生分为两组,使组内学生不认识: 现想将学生 ...

  4. JoyOI1391 走廊泼水节

    一道另类生成树 原题链接 将输入的树的\(n-1\)条边按从小到大排序,然后\(Kruskal\)在生成该树的过程中计算新增边的总长. 当在连第\(i\)条边,设该边的两端点为\(x,y\),长度为\ ...

  5. centos 7下安装mysql

    可参考: http://blog.csdn.net/xyang81/article/details/51759200 1.去mysql官方网站查询最新的版本: 2.运行指令: wget http:// ...

  6. BZOJ 3007 [SDOI2012]拯救小云公主 - 对偶图 + 并查集

    Solution 答案具有单调性, 显然可以二分答案. 有两个注意点 : 英雄是可以随便走的, 也就是不是网格图... 还有坐标不能小于$1$ QAQ 开始时英雄在左下角, 公主在右上角, 我们反过来 ...

  7. C#程序如何以管理员身份运行

    VISTA 和 Windows 7 都使用了UAC来控制程序访问,对于一些需要使用管理员身份运行的程序就得右键以管理员身份运行. C# 编程中可以使程序自动使用管理员身份运行,也就是我们常常看到一些程 ...

  8. readv writev示例程序

    当 readv() 时候,需要程序自己提供space,接收数据. #include <stdio.h> #include <stdlib.h> #include <str ...

  9. mysql8.0.4以后修改密码方式变更

    https://blog.csdn.net/qq_38265784/article/details/80915098 use mysql: ALTER USER 'root'@'localhost' ...

  10. JavaScript学习笔记:基础知识点总结

    基础概念 JavaScript(以下简称Js)中数据类型:Number 字符串 布尔值 数组 对象(Js的对象是一组由键值对组成的无序集合) Js中基础概念:变量(概念和Java中变量概念类似 指示某 ...