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. 15-BFC

    01 BFC官方解释 https://www.w3.org/TR/CSS2/visuren.html#normal-flow 大致意思如下 02 什么情况下会形成BFC MDN解释 https://d ...

  2. 移动web开发入门

    一,视口 <meta name="viewport" content="width=device-width, initial-scale=1, user-scal ...

  3. C语言的简单学习

    C语言是编译型语言,先编译再运行,通常用gcc进行编译,于是安装了Ubuntu操作系统.至于编辑器,VS Code也能用,先sudo apt install build-essential gdb,再 ...

  4. MySql 数据库、数据表操作

    数据库操作 创建数据库 语法 语法一:create database 数据库名 语法二:create database 数据库名 character set 字符集; 查看数据库 语法 查看数据库服务 ...

  5. 洛谷P1747

    这个题被坑麻了,题目居然不给棋盘的范围,评论区居然有人说棋盘是无限大的,我想说的是如果真是这样那么第9个点答案应该是2而不是3,这个棋盘绝对是有大小的. #include<iostream> ...

  6. Pytorch功能库留存

    初始化 首先,介绍我们导入的包和基础的网络结构 import torch import torch.nn as nn #可替代网络结构部分 ''' 神经网络类的定义 1. 输入卷积: in_chann ...

  7. 当一名有着 10w+ 听众的播客主播开始做 App

    名字: AAAny 开发者 / 团队: AAAny Team 平台: iOS 请简要介绍下这款产品 AAAny 是一个专为 AMA(我们称之为 AAA)设计的 App.多解释一下的话,其实 AAA 是 ...

  8. [oeasy]python0014_二进制_binary_bin

    ​ 二进制(binary) 回忆上次内容 上次我们了解了​​ASCII​​码表 ​ASCII​​ 码表就是 ​​A​​merican ​​S​​tandard ​​C​​ode for ​​I​​nf ...

  9. 修改PE文件来实现管理员权限

    在Windows我们常用的方法就是给应用添加app.manifest清单文件,然后生成的Exe就会具有管理员权限. 近期我在使用Wix制作Exe安装包时,发现此方法不通,我在github上和Stack ...

  10. Linux Kernel CFI机制简介及测试禁用

    PS:要转载请注明出处,本人版权所有. PS: 这个只是基于<我自己>的理解, 如果和你的原则及想法相冲突,请谅解,勿喷. 环境说明   无 前言   当我们为android移植linux ...