AtCoder Beginner Contest 189 Personal Editorial
第一次参加 AtCoder 的比赛,感觉还挺简单。
比赛链接:https://atcoder.jp/contests/abc189
A - Slot
// Author : RioTian
// Time : 21/01/23
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
int main() {
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
string s;
cin >> s;
if (s[0] == s[1] && s[1] == s[2])
cout << "Won\n";
else
cout << "Lost\n";
}
B - Alcoholic
高桥(大家都喜欢的高桥同学)要喝酒了,现在有n中酒,如果高桥同学喝酒的量大于 \(X \ ml\)则会喝酒离开酒席。那么请输出高桥是在第几个酒上喝醉了,如果没有喝醉请输出 -1
// Author : RioTian
// Time : 21/01/24
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
int main() {
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int n, v, p, x;
int sum = 0;
cin >> n >> x;
for (int i = 1; i <= n; ++i) {
cin >> v >> p;
sum += v * p;
if (sum > x * 100) {
cout << i << endl;
return 0;
}
}
cout << -1 << endl;
}
C - Mandarin
求最大连续序列和,但由于n比较小直接暴力即可。
// Author : RioTian
// Time : 21/01/24
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
int a[N];
int main() {
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int n;
cin >> n;
for (int i = 0; i < n; ++i) cin >> a[i];
int ans = 0;
for (int l = 0; l < n; ++l) {
int x = a[l];
for (int r = l; r < n; ++r) {
x = min(x, a[r]);
ans = max(ans, x * (r - l + 1));
}
}
cout << ans << endl;
}
D - Logical Expression
如果 \(S_i\) 是 AND 则 opt 设为 true,在之后只要 \(f(S_1,...,S_N) = f(S_1,...,S_{N-1})\)
如歌 \(S_i\) 是 OR 则 opt 设为 false,需要 \(f(S_1,...,S_N) = 2^N + f(S_1,...,S_{N-1})\)
// Author : RioTian
// Time : 21/01/24
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100;
ll dp[N][2];
bool opt[N];
string s;
int main() {
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> s;
if (s[0] == 'A')
opt[i] = true;
else
opt[i] = false;
}
dp[0][0] = dp[0][1] = 1;
for (int i = 1; i <= n; ++i) {
if (opt[i - 1]) {
dp[i][0] = 2 * dp[i - 1][0] + dp[i - 1][1];
dp[i][1] = dp[i - 1][1];
} else {
dp[i][0] = dp[i - 1][0];
dp[i][1] = 2 * dp[i - 1][1] + dp[i - 1][0];
}
}
cout << dp[n][1] << endl;
}
E,F比赛时没做就先鸽一下了
AtCoder Beginner Contest 189 Personal Editorial的更多相关文章
- 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 ...
随机推荐
- Kubernetes 中的服务注册与发现原理分析
公众号「架构成长指南」,专注于生产实践.云原生.分布式系统.大数据技术分享. 对k8s有点了解技术人员,应该都只知道k8s是有服务注册发现的,今天就分析下这个原理,看看怎么实现的. 什么是服务注册与发 ...
- jdk11的HttpClient
我们都知道在jdk11之前都在用okhttp或者org.apache.httpcomponents 其实早在jdk9的时候这个方案就在孵化中 上面的截图来自openjdk的官网,注:openjdk是 ...
- Linux下^m符号删除
Linux下^m符号删除 从Windows上复制的代码到Linux尾会有M字符,通过下命令可以删除. :%s/\r//
- [USACO2007NOVG] Telephone Wire G
题目描述 Farmer John's cows are getting restless about their poor telephone service; they want FJ to rep ...
- 解决URLEncoder.encode 编码空格变 + 号
jdk自带的URL编码工具类 URLEncoder 在对字符串进行URI编码的时候,会把空格编码为 + 号. 空格的URI编码其实是:%20 解决办法:对编码后的字符串,进行 + 号替换为 %20.总 ...
- 深度学习前沿 | 利用GAN预测股价走势
本文是对于medium上Boris博主的一篇文章的学习笔记,这篇文章中利用了生成对抗性网络(GAN)预测股票价格的变动,其中长短期记忆网络LSTM是生成器,卷积神经网络CNN是鉴别器,使用贝叶斯优化( ...
- 在蓝图中使用flask-restful
flask-restful中的Api如果传递整个app对象,那么就是整个flask应用都被包装成restful. 但是,你可以只针对某个蓝图(django中的子应用)来进行包装,这样就只有某个蓝图才会 ...
- Alpha-Beta剪枝的原理的深入理解(无图预警)
转载请注明 原文链接 :https://www.cnblogs.com/Multya/p/17929261.html 考虑一个树: 一棵树上只有叶子节点有值,有确定的根节点的位置 根据层数来划分叶子节 ...
- MagicArray基本使用方法
MagicArray致力于让研发不再卷,这个灵感来源于php语言,可能多少年以后,php可能不会有太多人记得.但是在一个年代里,如果论坛里里常见最火爆的帖子无疑是:php是世界上最好的编程语言.由此可 ...
- 大四jsp实训项目技术总结
crm项目总结 ①静态资源疯狂报错?很有可能是后端的问题,后端出了问题,服务器取不出来资源. 记住:只要服务器取不到某个资源,很有可能导致所有资源都取不出来. 一个经典案例:某个数据库映射文件 ICu ...