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. Java基础:throw和throws的详解

    总结来说,throw是用来抛出一个具体的异常实例,而throws是用来声明方法可能会抛出哪些类型的异常,是对调用者的一种通知和要求. 1. throw 作用: throw关键字用于在方法体内实际抛出一 ...

  2. golang执行命令 && 实时获取输出结果

    背景 golang可以获取命令执行的输出结果,但要执行完才能够获取. 如果执行的命令是ssh,我们要实时获取,并执行相应的操作呢? 示例 func main() { user := "roo ...

  3. 基于cifar数据集合成含开集、闭集噪声的数据集

    前言 噪声标签学习下的一个任务是:训练集上存在开集噪声和闭集噪声:然后在测试集上对闭集样本进行分类. 训练集中被加入的开集样本,会被均匀得打上闭集样本的标签充当开集噪声:而闭集噪声的设置与一般的噪声标 ...

  4. 79元国产ARM+DSP平台FFT实测分享

    T113-i国产ARM+DSP架构介绍 创龙科技SOM-TLT113是一款基于国产全志T113-i双核ARM Cortex-A7 +  HiFi4 DSP + 玄铁C906 RISC-V异构多核处理器 ...

  5. 合合TextIn - 大模型加速器

    TextIn是合合信息旗下的智能文档处理平台,在智能文字识别领域深耕17年,致力于图像处理.模式识别.神经网络.深度学习.STR.NLP.知识图谱等人工智能领域研究.凭借行业领先的技术实力,为扫描全能 ...

  6. MobaXterm是一款功能强大的远程SSH利器,是您远程计算机的终极工具箱

    MobaXterm 是一款功能强大的远程终端应用,可以用于 Windows 系统上的 SSH.Telnet.RDP.VNC 等远程登录.它支持多种会话类型,拥有强大的终端功能,还支持 X11 图形界面 ...

  7. PowerShell 使用 Azure

    PowerShell 使用 Azure Azure 提供了三种管理工具: Azure 门户:Azure 门户是一个网站,可在其中创建.配置和更改 Azure 订阅中的资源,该门户是一个图形用户界面 ( ...

  8. vue小知识~ref和$refs

    $refs表示的是获取被ref标识的标签的DM实例. 用法简单: 标签上: <div ref='refName'></div> 获取: this.$refs.refName 就 ...

  9. Aug. 2024 杭二训练游记

    \(\text{前言}\) 我在 \(\text{Aug. 6th}\) 到 \(\text{Aug. 25th}\) 在杭州某知名中学集训,但是我亲爱的母亲却在一开始告诉我是 \(\text{Aug ...

  10. PHP进阶

    只是简要说明起原理和用法,具体可以百度 abstract 抽象类 抽象类是指在 class 前加了 abstract 关键字且存在抽象方法,不带{},如public function test() i ...