Atcoder ABC 141
Atcoder ABC 141
A - Weather Prediction
SB题啊,不讲。
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char ch[50];
int main() {
scanf("%s",ch+1);
if(ch[1] == 'S') puts("Cloudy");
if(ch[1] == 'C') puts("Rainy");
if(ch[1] == 'R') puts("Sunny");
//system("pause");
return 0;
}
B - Tap Dance
暴力判断每一位是否合法就行。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define LL long long
#define N 100010
char ch[N];
bool flag = 1;
int main() {
scanf("%s",ch+1);
int len = strlen(ch + 1);
for(int i = 1 ; i <= len ; i++) {
if(i % 2 == 1) {
if(ch[i] == 'R' || ch[i] == 'U' || ch[i] == 'D') continue;
else {
flag = 0;
break;
}
}
if(i % 2 == 0) {
if(ch[i] == 'L' || ch[i] == 'U' || ch[i] == 'D') continue;
else {
flag = 0;
break;
}
}
}
if(flag) puts("Yes");
else puts("No");
//system("pause");
return 0;
}
C - Attack Survival
直接暴力会T的飞起,所以需要优化。
因为每一轮除了回答问题的人,其他人的值全部 $ -1 $ 。
所以我们可以考虑先全部 $ -1 $ ,再对回答问题的人 $ +1 $ 即可。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define LL long long
const int N = 1e5 + 100;
int a[N],n,k,q,x;
int main() {
scanf("%d%d%d",&n,&k,&q);
for(int i = 1 ; i <= n ; i++) a[i] = k - q;
/*while(q--) {
scanf("%d",&x);
for(int i = 1 ; i <= n ; i++) a[i]--;
a[x]++;
}*/
while(q--) {
scanf("%d",&x);
a[x]++;
}
for(int i = 1 ; i <= n ; i++) {
if(a[i] > 0) puts("Yes");
else if(a[i] <= 0) puts("No");
}
//system("pause");
return 0;
}
D - Powerful Discount Tickets
贪心,拿个堆维护一下。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
#define LL long long
const int N = 1e5 + 100;
LL num[N],dis,m,n;
priority_queue<LL> qu;
inline int fast_pow(int x, int y) {
int ans = 1;
while(y) {
if(y & 1) ans = x * ans;
y >>= 1;
x = x * x;
}
return ans;
}
int main() {
scanf("%lld%lld",&n,&m);
for (int i = 1; i <= n; i++) {
scanf("%lld",&num[i]);
qu.push(num[i]);
}
if (n == 1) {
if(log2(num[1]) + 1 <= m) puts("0");
else printf("%lld\n", num[1] / fast_pow (2, m));
return 0;
}
while(m) {
int now = qu.top();
if(now == 0) break;
qu.pop();
int cost = 0;
if(qu.top() == 0) {
if(log2 (now) + 1 <= m) qu.push(0);
else qu.push(now/fast_pow(2, m));
break;
}
while(now/fast_pow(2, cost) - now/fast_pow(2, cost + 1) >= qu.top() - qu.top()/2 && cost + 1 <= m) cost++;
m -= cost;
qu.push(now/fast_pow(2, cost));
}
while(!qu.empty()) {
dis += qu.top();
qu.pop();
}
printf("%lld\n", dis);
//system("pause");
return 0;
}
E - Who Says a Pun?
直接SA,没了。
Atcoder ABC 141的更多相关文章
- AtCoder abc 141 F - Xor Sum 3(线性基)
传送门 题意: 给出\(n\)个数\(a_i\),现在要将其分为两堆,使得这两堆数的异或和相加最大. 思路: 考虑线性基贪心求解. 但直接上线性基求出一组的答案是行不通的,原因之后会说. 注意到如果二 ...
- ATCODER ABC 099
ATCODER ABC 099 记录一下自己第一场AK的比赛吧...虽然还是被各种踩... 只能说ABC确实是比较容易. A 题目大意 给你一个数(1~1999),让你判断它是不是大于999. Sol ...
- Atcoder ABC 139E
Atcoder ABC 139E 题意: n支球队大循环赛,每支队伍一天只能打一场,求最少几天能打完. 解法: 考虑抽象图论模型,既然一天只能打一场,那么就把每一支球队和它需要交手的球队连边. 求出拓 ...
- Atcoder ABC 139D
Atcoder ABC 139D 解法: 等差数列求和公式,记得开 $ long long $ CODE: #include<iostream> #include<cstdio> ...
- Atcoder ABC 139C
Atcoder ABC 139C 题意: 有 $ n $ 个正方形,选择一个起始位置,使得从这个位置向右的小于等于这个正方形的高度的数量最多. 解法: 简单递推. CODE: #include< ...
- Atcoder ABC 139B
Atcoder ABC 139B 题意: 一开始有1个插口,你的插排有 $ a $ 个插口,你需要 $ b $ 个插口,问你最少需要多少个插排. 解法: 暴力模拟. CODE: #include< ...
- Atcoder ABC 139A
Atcoder ABC 139A 题意: 给你两个字符串,记录对应位置字符相同的个数 $ (n=3) $ 解法: 暴力枚举. CODE: #include<iostream> #inclu ...
- atcoder abc 244
atcoder abc 244 D - swap hats 给定两个 R,G,B 的排列 进行刚好 \(10^{18}\) 次操作,每一次选择两个交换 问最后能否相同 刚好 \(10^{18}\) 次 ...
- AtCoder ABC 250 总结
AtCoder ABC 250 总结 总体 连续若干次一样的结果:30min 切前 4 题,剩下卡在 T5 这几次卡在 T5 都是一次比一次接近, 什么 dp 前缀和打挂,精度被卡,能水过的题连水法都 ...
随机推荐
- Excel VBA 入门基础
Private Sub RegExp_Replace() Dim RegExp As Object Dim SearchRange As Range, Cell As Range '此处定义正则表达式 ...
- NetCore.SignalR.Demo演示
项目github,点击https://github.com/wangpengzong/NetCore.SignalR.Demo 1.打开服务端Server(\SignalR.Server\bin\De ...
- Mybatis之日志工厂
思考:我们在测试SQL的时候,要是能够在控制台输出 SQL 的话,是不是就能够有更快的排错效率? 如果一个 数据库相关的操作出现了问题,我们可以根据输出的SQL语句快速排查问题. 对于以往的开发过程, ...
- Sql Server 2017 安装问题记录
记录了我在虚拟机中安装Sql server 2017遇到的一些问题. 安装环境: Sql server 2017 + Windows Server 2012 R2 提供两个网上的下载链接: https ...
- 创建第一kubernetes应用以及基本操作(六)
1.创建一个测试用的deployment kubectl run net-test --image=alpine --replicas= sleep 2.查看获取IP情况 [root@linux ~] ...
- Eclipse启动tomcat超时
启动tomcat 超时 Server Tomcat v8.0 Server at localhost was unable to start within 45 seconds. If the ser ...
- markdown demo 学习
## <center>2019-05-08 12:05 DDoS攻击检测报告</center> ## - **MME ID**: 1123424 - **DDoS攻击类型**: ...
- linux网络编程之posix条件变量
今天来学习posix的最后一个相关知识----条件变量,言归正传. 下面用一个图来进一步描述条件变量的作用: 为什么呢? 这实际上可以解决生产者与消费者问题,而且对于缓冲区是无界的是一种比较理解的解决 ...
- java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)解决方案
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) at com.mysql. ...
- JAVA API连接HDFS HA集群
使用JAVA API连接HDFS时我们需要使用NameNode的地址,开启HA后,两个NameNode可能会主备切换,如果连接的那台主机NameNode挂掉了,连接就会失败. HDFS提供了names ...