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的更多相关文章

  1. 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\ ...

  2. UOJ Round #15 [构造 | 计数 | 异或哈希 kmp]

    UOJ Round #15 大部分题目没有AC,我只是水一下部分分的题解... 225[UR #15]奥林匹克五子棋 题意:在n*m的棋盘上构造k子棋的平局 题解: 玩一下发现k=1, k=2无解,然 ...

  3. BestCoder Round#15 1001-Love

    http://acm.hdu.edu.cn/showproblem.php?pid=5082 Love Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  4. HYNB Round 15: PKU Campus 2019

    HYNB Round 15: PKU Campus 2019 C. Parade 题意 将平面上n*2个点安排在长度为n的两行上. 做法 首先可以忽略每个点之间的影响,只用考虑匹配即可 然后把所以点归 ...

  5. 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 ...

  6. 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 ...

  7. Educational Codeforces Round 15 C. Cellular Network(二分)

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  8. Educational Codeforces Round 15 C 二分

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  9. Educational Codeforces Round 15 A dp

    A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...

  10. 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 ...

随机推荐

  1. Caffe样例中mnist的文件之间逻辑分析

    约定一下,Caffe运行样例时在终端中使用的所有命令,同时终端中的目录已经cd到Caffe之中(别告诉我一个Github项目你还没有make all就直接拿过来用了) sudo sh data/mni ...

  2. 基于SQLite3的C学习总结

    背景 针对 SQLite3 的学习总结 arm linux 移植 SQLite 3 如何在 Linux 上移植使用 SQLite3,标题虽然是在讲 arm linux,但实际上是跨平台的. 基于 SQ ...

  3. mapreduce压缩

    这是mr的一种优化策略,通过压缩编码对mapper或者reducer的输出进行压缩,以减少磁盘io,提高mr运行速度(但也相应增加了cpu运算负担) 特性: 1.mr支持将map输出的结果或者redu ...

  4. 【Python】Pandas操作Excel

    一:Pandas操作Excel 1.1: 创建/读取excel文件 读取excel pd.read_excel(filepath) 读取指定标题行 pd.read_excel(filepath,hea ...

  5. Python 潮流周刊#59:Polars 1.0 发布了,PyCon US 2024 演讲视频也发布了(摘要)

    本周刊由 Python猫 出品,精心筛选国内外的 250+ 信息源,为你挑选最值得分享的文章.教程.开源项目.软件工具.播客和视频.热门话题等内容.愿景:帮助所有读者精进 Python 技术,并增长职 ...

  6. docker-compose的使用和常用命令

    Docker简介 Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中,然后发布到任何流行的 Linux或Windows操作系统的机器上,也可以实现虚拟化. ...

  7. mac idea 配置Tomcat

    官网下载Tomcat 下载地址:点我直达 配置Idea 设置Application Servers 操作步骤:Intellij IDEA->Preferences->Application ...

  8. 最简GIF解析代码gif_jumper,用于stb_image的小改进

    gif jumper gif支持多帧动画,但是没有存储总帧数,解析gif直到结束才能知道总帧数. 所以gif解析代码,要么采用链表,要么不停realloc()分配内存,stb_image的代码就是如此 ...

  9. MoneyPrinterPlus全面支持本地Ollama大模型

    MoneyPrinterPlus现在支持批量混剪,一键AI生成视频,一键批量发布短视频这些功能了. 之前支持的大模型是常用的云厂商,比如OpenAI,Azure,Kimi,Qianfan,Baichu ...

  10. PN转Modbus RTU模块连接ACS4QQ变频器通信

    一台完整的机器在出厂前由许多部件组成.但是,由于各种原因,这些组件来自不同的制造商,导致设备之间的通信协议存在差异.Modbus和Profinet代表两种不同的通信协议,Profinet通常用于较新的 ...