SMU Summer 2023 Contest Round 15
SMU Summer 2023 Contest Round 15
A. AB Balance
其实就只会更改一次
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T--){
string s;
cin >> s;
int ba = 0, ab = 0;
int n = s.size();
for(int i = 0;i < n - 1;i ++){
if(s.substr(i,2) == "ab") ab ++;
else if(s.substr(i,2) == "ba") ba++;
}
if(ab == ba){
cout << s << '\n';
}else{
if(ba > ab){
s[0] = 'a';
cout << s << '\n';
}else{
s.back() = 'a';
cout << s << '\n';
}
}
}
return 0;
}
B. Update Files
模拟第一个样例\(1,2,4,7,8...\),其实前面就是\(1 \sim 2^{k-1}\),后面多出来的去除以\(k\)向上取整就可以了
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int n,k;
cin >> n >> k ;
int ans = 0,m = 1;
while(m < k && m < n){
m *= 2;
ans ++;
}
cout << ans + (max(0ll, n - m) + k - 1) / k << '\n';
}
return 0;
}
C. Banknotes
如果小的凑不成,大的肯定也凑不成,所以我们要从小去枚举,枚举当前能进位的纸币数小于\(k\)张,否则的话就加上\(k+1\)张就行了.
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int n,k;
cin >> n >> k;
vector<int> a(n);
for(auto &i : a) cin >> i;
vector<int> b(n);
for(int i = 0;i < n - 1;i ++){
b[i] = (int)pow(10,a[i + 1] - a[i]) - 1;
}
b[n - 1] = 1e10;
int ans = 0;
for(int i = 0;i < n;i ++){
if(b[i] > k){
ans += (k + 1) * (int)pow(10,a[i]);
break;
}else{
ans += b[i] * (int)pow(10,a[i]);
k -= b[i];
}
}
cout << ans << '\n';
}
return 0;
}
SMU Summer 2023 Contest Round 15的更多相关文章
- 2015 German Collegiate Programming Contest (GCPC 15) + POI 10-T3(12/13)
$$2015\ German\ Collegiate\ Programming\ Contest\ (GCPC 15) + POI 10-T3$$ \(A.\ Journey\ to\ Greece\ ...
- UOJ Round #15 [构造 | 计数 | 异或哈希 kmp]
UOJ Round #15 大部分题目没有AC,我只是水一下部分分的题解... 225[UR #15]奥林匹克五子棋 题意:在n*m的棋盘上构造k子棋的平局 题解: 玩一下发现k=1, k=2无解,然 ...
- BestCoder Round#15 1001-Love
http://acm.hdu.edu.cn/showproblem.php?pid=5082 Love Time Limit: 2000/1000 MS (Java/Others) Memory ...
- HYNB Round 15: PKU Campus 2019
HYNB Round 15: PKU Campus 2019 C. Parade 题意 将平面上n*2个点安排在长度为n的两行上. 做法 首先可以忽略每个点之间的影响,只用考虑匹配即可 然后把所以点归 ...
- Codeforces Educational Codeforces Round 15 C. Cellular Network
C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Educational Codeforces Round 15 A. Maximum Increase
A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 15 C. Cellular Network(二分)
C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 15 C 二分
C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 15 A dp
A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Educational Codeforces Round 15 E - Analysis of Pathes in Functional Graph
E. Analysis of Pathes in Functional Graph time limit per test 2 seconds memory limit per test 512 me ...
随机推荐
- /etc/shadow文件破解,密码破解,md5,SHA256,SHA512破解
环境 Kali系统 John the Ripper密码破解者 shadow文件解析 文件的格式为: {用户名}:{加密后的口令密码}:{口令最后修改时间距原点(1970-1-1)的天数}:{口令最小修 ...
- ClickHouse特性及底层存储原理
ClickHouse的特性 ClickHouse是一款MPP架构的列式存储数据库,但MPP和列式存储并不是什么"稀罕"的设计.拥有类似架构的其他数据库产品也有很多,但是为什么偏偏只 ...
- Linux 内核:设备驱动模型(1)sysfs与kobject基类
Linux 内核:设备驱动模型(1)sysfs与kobject基类 背景 学习Linux 设备驱动模型时,对 kobject 不太理解.因此,学习了一下. 现在我知道了:kobj/kset是如何作为统 ...
- bs4解析-湖南农场品价格行情
import requests from bs4 import BeautifulSoup import csv url = 'https://price.21food.cn/market/174-p ...
- Gitbook的安装和部署
安装 npm install gitbook-cli -g gitbook命令: gitbook init //初始化目录文件 gitbook help //列出gitbook所有的命令 gitboo ...
- UG 2406 python 二次开发环境配置
UG 2406 python 二次开发环境配置 项目地址 https://gitee.com/unm001/nx2406.git 安装python 安装 python 3.10.11 D:\prog\ ...
- Django DRF @action 装饰器
@action 装饰器在Django REST Framework (DRF) 中非常有用,它可以帮助你在ViewSet中创建自定义的动作,而不仅仅是依赖标准的CRUD操作(Create, Read, ...
- oeasy教您玩转vim - 88 - # 自动命令autocmd
自动命令 autocommand 回忆 上次我们研究的是外部命令grep 可以在vim中使用grep 搜索的结果进入了列表 可以打开.遍历.跳转.关闭这个列表 也可以给列表中的匹配行或者每个文件执 ...
- NOIP2023
坐标HA 背景 打完CSP-S后觉得自主招生稳了,就想着NOIP摆烂,所以此游记仅仅是为了凑数. 正文 Day 0 不出所料,机房统一集训,但是在CSP集训后导致的期中挂分的影响下,这一想法被家长以及 ...
- 30K Star,最全面的PDF处理开源项目,你也可以拥有一个本地的PDF处理大全
大家好,我是程序猿DD 今天给大家推荐一个日常大概率能用上的开源项目:Stirling PDF 开源地址:https://github.com/Stirling-Tools/Stirling-PDF ...