SMU Summer 2023 Contest Round 15

A. AB Balance

其实就只会更改一次

  1. #include <bits/stdc++.h>
  2. #define int long long
  3. using namespace std;
  4. signed main() {
  5. ios::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7. int T;
  8. cin >> T;
  9. while(T--){
  10. string s;
  11. cin >> s;
  12. int ba = 0, ab = 0;
  13. int n = s.size();
  14. for(int i = 0;i < n - 1;i ++){
  15. if(s.substr(i,2) == "ab") ab ++;
  16. else if(s.substr(i,2) == "ba") ba++;
  17. }
  18. if(ab == ba){
  19. cout << s << '\n';
  20. }else{
  21. if(ba > ab){
  22. s[0] = 'a';
  23. cout << s << '\n';
  24. }else{
  25. s.back() = 'a';
  26. cout << s << '\n';
  27. }
  28. }
  29. }
  30. return 0;
  31. }

B. Update Files

模拟第一个样例\(1,2,4,7,8...\),其实前面就是\(1 \sim 2^{k-1}\),后面多出来的去除以\(k\)向上取整就可以了

  1. #include <bits/stdc++.h>
  2. #define int long long
  3. using namespace std;
  4. signed main() {
  5. ios::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7. int T;
  8. cin >> T;
  9. while(T--){
  10. int n,k;
  11. cin >> n >> k ;
  12. int ans = 0,m = 1;
  13. while(m < k && m < n){
  14. m *= 2;
  15. ans ++;
  16. }
  17. cout << ans + (max(0ll, n - m) + k - 1) / k << '\n';
  18. }
  19. return 0;
  20. }

C. Banknotes

如果小的凑不成,大的肯定也凑不成,所以我们要从小去枚举,枚举当前能进位的纸币数小于\(k\)张,否则的话就加上\(k+1\)张就行了.

  1. #include <bits/stdc++.h>
  2. #define int long long
  3. using namespace std;
  4. signed main() {
  5. ios::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7. int T;
  8. cin >> T;
  9. while(T--){
  10. int n,k;
  11. cin >> n >> k;
  12. vector<int> a(n);
  13. for(auto &i : a) cin >> i;
  14. vector<int> b(n);
  15. for(int i = 0;i < n - 1;i ++){
  16. b[i] = (int)pow(10,a[i + 1] - a[i]) - 1;
  17. }
  18. b[n - 1] = 1e10;
  19. int ans = 0;
  20. for(int i = 0;i < n;i ++){
  21. if(b[i] > k){
  22. ans += (k + 1) * (int)pow(10,a[i]);
  23. break;
  24. }else{
  25. ans += b[i] * (int)pow(10,a[i]);
  26. k -= b[i];
  27. }
  28. }
  29. cout << ans << '\n';
  30. }
  31. return 0;
  32. }

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. 链表中,LNode和* LinkList的理解

    typedef struct LNode { int data; struct LNode* next; }LNode, * LinkList; 这是标准链表创建法. 简单的说,其中LNode和 * ...

  2. 异构智联Wi-Fi6+蓝牙模组,重新定义多屏互联体验!

    下班回家打开门,电灯.电视.空调.音响.电动窗帘.扫地机器人--一呼百应,有序开工,原本冰冷的房子立刻变成了温暖港湾.可以说,舒适便捷的智能设备已经完全融入了我们的生活中. 从单一场景.单一设备,到现 ...

  3. do{}while0的两个作用

    1.作为一种防止宏错误展开的一种防御性写法. 相信很多人都知道,这里不展开了. 2.实现 goto 语句的功能,一次break就可以跳出到后续语句. do { if(...) break; ... } ...

  4. ​Chrome插件:Postman Interceptor 调试的终极利器

    今天给大家介绍一款非常实用的工具--Postman Interceptor. 这个工具可以捕捉任何网站的请求,并将其发送到Postman客户端. 对于经常和API打交道的程序员来说,Postman I ...

  5. CF372C

    思路 根据题意可以得到dp转移方程是 \(f_{i,j}=\max\{f_{i-1,k}+b_i-|a_i-j|\}\) 而且 \(j-(t_{i}-t_{i-1})\times d\le k\le ...

  6. cf edu 133 D

    题意 思路 根据题意,最开始可以想到一个二维的dp状态 用dp[i][j]表示跳了j次刚好到i的方案数 如果是跳了j次,那么这次应该要被k+j-1整除才行 那么这样状态转移就是 dp[i][j] = ...

  7. SQLServer的操作以及一些概念

    初始SQLServer 创建数据库 create database 数据库名 创建表 选择数据库 USE MyDb; 创建表 CREATE TABLE t_user ( id INT, usernam ...

  8. PHP str_replace() 函数详解

    PHP str_replace() 函数详解 1.前言: str_replace() 函数以其他字符替换字符串中的一些字符(区分大小写). 该函数区分大小写.请使用 str_ireplace() 函数 ...

  9. 【译】使 Visual Studio 更加可视化

    任何 Web.桌面或移动开发人员都经常使用图像.你可以从 C#.HTML.XAML.CSS.C++.VB.TypeScript 甚至代码注释中引用它们.有些图像是本地的,有些存在于线上或网络共享中,而 ...

  10. Top monitor[2.1.11] 开源

    说明 本项目将转为开源项目. \(\text{GitHub}\) 仓库下载链接 \(|\) 项目初始化下载 \(|\) 项目编辑文件下载. 项目说明 声明:此项目由 \(\text{So_noSlac ...