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 ...
随机推荐
- iOS开发流程总结(新坑持续更新)
[上线前流程] 将测试环境修改成正式环境 修改版本号,而且build version比version多一位,如version设置为1.0.1,那么build就设置成1.0.1.x:这么做的理由是,当你 ...
- .NET 高效灵活的API速率限制解决方案
前言 FireflySoft.RateLimit是基于.NET Core和.NET Standard构建,支持多种速率限制算法和策略,包括固定窗口.滑动窗口.漏桶.令牌桶等.通过简单的配置和集成,开发 ...
- CAP 8.2 版本发布通告
前言 今天我们很高兴宣布 CAP 发布 8.2 版本正式版,我们在这个版本中主要致力于对订阅着并行执行的特性提供支持,同时添加了对在订阅者中对消息头的控制行为. 下面,具体看一下我们新版本的功能吧. ...
- 使用 nginx 共享文件
1. 安装nginx 2. 在nginx的配置文件的server部分加上如下的配置: location /shared/ { autoindex on; autoindex_exact_size on ...
- 【简单总结】SLAM 算法的 Benchmark 及相关数据集的结果对比
前言与参考 主要是copy一下总结,方便自己后续找方案特定使用,所有的出处均在标题处和原链接跳转,此处仅做各个benchmark收集使用,如果有原作者觉得侵权,请联系我 将全力配合相关内容和链接删除 ...
- 【ClickHouse】2:clickhouse基本语法
背景介绍: 有三台CentOS7服务器安装了ClickHouse HostName IP 安装程序 程序端口 centf8118.sharding1.db 192.168.81.18 clickhou ...
- AX网相关图片(原创)
官网:AXA6.COM | The future is come. Copyright 2020 – 2023| AX网 Axa6.Com | All Rights Reserved
- BTC 地址
比特币地址(Bitcoin Address)是用于接收和发送比特币的唯一标识符,类似于传统金融系统中的银行账号.一个比特币地址由一串字母和数字组成,通常以1.3或bc1开头,具体长度为26至35个字符 ...
- 单细胞测序最好的教程(八): 细胞类型自动注释-1|基于marker的自动注释
作者按 本章节主要讲解了基于marker的自动注释方法,一般来说,我会先自动注释,再手动去确认marker,这是因为,对于一个陌生的组织,我对marker是不了解的,自动注释可以帮助我快速熟悉细胞类型 ...
- Charles抓包配置、常见问题和解决方法
1.下载安装charles,官方下载地址:https://www.charlesproxy.com/download/ 如图,下载所对应系统需要的相应版本即可. 2.解压Charles包,双击Char ...