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 前缀和打挂,精度被卡,能水过的题连水法都 ...
随机推荐
- PDA无线移动开单智能新生活,省时、省心、省力
纯手工4个小时 VS移动PDA开单10分钟 无论你是营业办公还是需要上门接货,开单都是一件重要且繁琐的事情.我们了解到传统物流业务运营都是通过手抄单.表格.补录运单来重复操作每一笔业务,手动填写纸质单 ...
- 编写一个stm32 svc关中断函数
做到了让stm32触发svc中断并传递进去参数然后切换到handler模式并修改特殊寄存器的值,从而达到关中断,但是其实这个程序直接就是特权级,故不进入handler模式也可以修改特殊寄存器..... ...
- rhel7下安装EPEL源
1.rhel7安装aliyun下的epel源 wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
- kali linux Desktop Environemt types and kali linux install virualbox
1.we know the kali linux desktop environmet can also be costomized ,Desktop environmet can use GNOME ...
- 每日一题-——LeetCode(617) 合并二叉树
题目描述: 给定两个二叉树,想象当你将它们中的一个覆盖到另一个上时,两个二叉树的一些节点便会重叠.你需要将他们合并为一个新的二叉树.合并的规则是如果两个节点重叠,那么将他们的值相加作为节点合并后的新值 ...
- Visual Studio 快捷键、常见问题
前言 由于平时自己在使用 VS 过程中遇到过一些很常见的问题,比如基本的设置.工具等.VS 十分的强大(宇宙第一 IDE),所以有些功能藏的深也不好找,就在这里记录下. 正文 一.快捷操作 1.调试. ...
- LoadRunner在Controller场景中配置获取Windows Resources
一.首先需要在被监控Windows服务器端(只支持Windows)进行如下设置: 启动服务: Remote Procedure Call (RPC) RemoteRegistry 操作方法: 按Win ...
- Jenkins 参数化构建(Git Parameter)
由于我们在测试过程中,可能需要在多个测试环境跑用例,这个时候就需要jenkins参数化了. Jenkins参数化一般常用的有两种方式:Choice和String Parameter两种 (1)Choi ...
- vue npm,Git随笔
下载模块: npm install <package-name> --save-dev 上线: npm run build 基本使用流程:1. npm install vue-cli - ...
- fs模块
fs.readdir(path, callback) 异步读取目录下文件 path - 文件路径. callback - 回调函数,回调函数带有两个参数err, files,err 为错误信息,fil ...