Codeforces Round 993 (Div. 4)

Codeforces Round 993 (Div. 4)

2024.12.15 rank289 +123:1381->1504

A

Cube is given an integer n n n. She wants to know how many ordered pairs of positive integers ( a , b ) (a,b) (a,b) there are such that a = n − b a=n-b a=nb. Since Cube is not very good at math, please help her!

B

A string consisting of only characters ‘p’, ‘q’, and ‘w’ is painted on a glass window of a store. Ship walks past the store, standing directly in front of the glass window, and observes string a a a. Ship then heads inside the store, looks directly at the same glass window, and observes string b b b.

Ship gives you string a a a. Your job is to find and output b b b.

C

Ball is the teacher in Paperfold University. The seats of his classroom are arranged in 2 2 2 rows with m m m seats each.

Ball is teaching a + b + c a + b + c a+b+c monkeys, and he wants to assign as many monkeys to a seat as possible. Ball knows that a a a of them only want to sit in row 1 1 1, b b b of them only want to sit in row 2 2 2, and c c c of them have no preference. Only one monkey may sit in each seat, and each monkey’s preference must be followed if it is seated.

What is the maximum number of monkeys that Ball can seat?

D

Given a sequence of positive integers, a positive integer is called a mode of the sequence if it occurs the maximum number of times that any positive integer occurs. For example, the mode of [ 2 , 2 , 3 ] [2,2,3] [2,2,3] is 2 2 2. Any of 9 9 9, 8 8 8, or 7 7 7 can be considered to be a mode of the sequence [ 9 , 9 , 8 , 8 , 7 , 7 ] [9,9,8,8,7,7] [9,9,8,8,7,7].

You gave UFO an array a a a of length n n n. To thank you, UFO decides to construct another array b b b of length n n n such that a i a_i ai is a mode of the sequence [ b 1 , b 2 , … , b i ] [b_1, b_2, \ldots, b_i] [b1,b2,,bi] for all 1 ≤ i ≤ n 1 \leq i \leq n 1in.

However, UFO doesn’t know how to construct array b b b, so you must help her. Note that 1 ≤ b i ≤ n 1 \leq b_i \leq n 1bin must hold for your array for all 1 ≤ i ≤ n 1 \leq i \leq n 1in.

E

Wave is given five integers k k k, l 1 l_1 l1, r 1 r_1 r1, l 2 l_2 l2, and r 2 r_2 r2. Wave wants you to help her count the number of ordered pairs ( x , y ) (x, y) (x,y) such that all of the following are satisfied:

  • l 1 ≤ x ≤ r 1 l_1 \leq x \leq r_1 l1xr1.
  • l 2 ≤ y ≤ r 2 l_2 \leq y \leq r_2 l2yr2.
  • There exists a non-negative integer n n n such that y x = k n \frac{y}{x} = k^n xy=kn.

G1

This is the easy version of the problem. The key difference between the two versions is highlighted in bold.

A group of n n n spiders has come together to exchange plushies. Initially, each spider has 1 1 1 plushie. Every year, if spider i i i has at least one plushie, he will give exactly one plushie to spider r i r_i ri. Otherwise, he will do nothing. Note that all plushie transfers happen at the same time. In this version, if any spider has more than 1 1 1 plushie at any point in time, they will throw all but 1 1 1 away.

The process is stable in the current year if each spider has the same number of plushies (before the current year’s exchange) as he did the previous year (before the previous year’s exchange). Note that year 1 1 1 can never be stable.

Find the first year in which the process becomes stable.

------------------------独自思考分割线------------------------

  • nice!!

A

  1. 发现答案为n-1。

B

  1. 首先字符反转,p/q再反转。

C

  1. 贪心a,b,再贪心c。

D

  1. 比较有意思的构造。

E

  1. 暴力思路肯定会T,考虑优化:发现合法的对于每个k,合法区间 l 1 ≤ l ≤ r ≤ r 1 l_1 \leq l \leq r \leq r_1 l1lrr1
  2. 同时k的取值很小。考虑两次二分找合法范围。

G1

  1. 模拟过程找到循环。

------------------------代码分割线------------------------

A

#include <bits/stdc++.h>
#define int long long //
#define endl '\n'     // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);cout << fixed << setprecision(6);int T = 1;cin >> T;while (T--)_();return 0;
}void _()
{int n;cin >> n;cout << n - 1 << endl;
}

B

#include <bits/stdc++.h>
#define int long long //
#define endl '\n'     // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);cout << fixed << setprecision(6);int T = 1;cin >> T;while (T--)_();return 0;
}void _()
{string s;cin >> s;reverse(s.begin(), s.end());for (auto &v : s)if (v - 'w')v = v == 'p' ? 'q' : 'p';cout << s << endl;
}

C

#include <bits/stdc++.h>
#define int long long //
#define endl '\n'     // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);cout << fixed << setprecision(6);int T = 1;cin >> T;while (T--)_();return 0;
}void _()
{int m, a, b, c;cin >> m >> a >> b >> c;int res = 0, n1 = m, n2 = m;res += min(n1, a);n1 -= min(n1, a);res += min(n2, b);n2 -= min(n2, b);res += min(n1 + n2, c);cout << res << endl;
}

D

#include <bits/stdc++.h>
#define int long long //
#define endl '\n'     // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);cout << fixed << setprecision(6);int T = 1;cin >> T;while (T--)_();return 0;
}void _()
{int n;cin >> n;vector<int> a(n);map<int, int> has, in;for (int &v : a)cin >> v, has[v] = 1;queue<int> no_has;for (int i = 1; i <= n; i++)if (!has[i])no_has.push(i);for (int i = 0; i < n; i++)if (i){if (a[i] == a[i - 1] || in[a[i]]){cout << no_has.front() << ' ';in[no_has.front()] = 1;no_has.pop();}elsecout << a[i] << ' ', in[a[i]] = 1;}elsecout << a[i] << " ", in[a[i]] = 1;cout << endl;
}

E

#include <bits/stdc++.h>
#define int long long //
#define endl '\n'     // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);cout << fixed << setprecision(6);int T = 1;cin >> T;while (T--)_();return 0;
}void _()
{int k, l1, r1, l2, r2;cin >> k >> l1 >> r1 >> l2 >> r2;int base = 1;int res = 0;for (; l1 * base <= r2; base *= k){int l = l1 - 1, r = r1 + 1;while (r - l - 1){int mid = l + r >> 1;if (mid * base <= r2)l = mid;elser = mid;}// bug2(l, l * base);int u = l;if (u < l1)continue;l = l1 - 1, r = u + 1;while (r - l - 1){int mid = l + r >> 1;if (mid * base >= l2)r = mid;elsel = mid;}if (r > u)continue;res += u - r + 1;}cout << res << endl;
}

G1

#include <bits/stdc++.h>
#define int long long //
#define endl '\n'     // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);cout << fixed << setprecision(6);int T = 1;cin >> T;while (T--)_();return 0;
}void _()
{int n;cin >> n;vector<int> a(n + 1);map<int, int> has;for (int i = 1; i <= n; i++){cin >> a[i];has[a[i]]++;}vector<int> no_has;for (int i = 1; i <= n; i++)if (!has[i])no_has.push_back(i);for (int i = 2;; i++){if (no_has.size() == 0){cout << i << endl;return;}vector<int> vec;for (auto v : no_has){has[a[v]]--;if (has[a[v]] == 0)vec.push_back(a[v]);}no_has = vec;}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/490975.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Linux中的service命令

service命令 在Linux系统中&#xff0c;service命令是用来启动、停止、重启以及查看系统服务状态的一个常用命令。服务&#xff0c;或称为守护进程&#xff0c;是在后台运行的进程&#xff0c;它们通常会监听某个端口&#xff0c;等待其他程序的请求。例如&#xff0c;MySQL、…

R环境配置 以及Debug方法 (VSCode, conda, 远程R)

生物信息学中的R环境配置 以及Debug方法 开始设置1、建议使用VSCode conda 远程R2、 VSCode配置安装插件安装好插件后&#xff0c;远程设置链接成功后&#xff0c;设置项目 3、 linux conda 和 远程R配置4、VScode 远程访问R环境下面配置远程R 5、开始Debug新建个R文件&#…

druid图形化监控 + MyBatis优化器使用

文章目录 1.集成druid图形化监控1.配置application.yml2.测试访问 http://localhost:项目端口/druid 2.MyBatis优化器(显示完整sql)1.目录2.SqlBeautyInterceptor.java&#xff1a;sql拦截器3.MybatisConfiguration.java&#xff1a;将sql拦截器注入容器4.测试5.MyBatis优化器动…

【经验分享】私有云运维的知识点

最近忙于备考没关注&#xff0c;有次点进某小黄鱼发现首页出现了我的笔记还被人收费了 虽然我也卖了一些资源&#xff0c;但我以交流、交换为主&#xff0c;笔记都是免费给别人看的 由于当时刚刚接触写的并不成熟&#xff0c;为了避免更多人花没必要的钱&#xff0c;所以决定公…

Unity 2020、2021、2022、2023、6000下载安装

Unity 2020、2021、2022、2023、6000 下载安装 以Unity 6000.0.24fc1下载安装为例&#xff1a; 打开 https://unity.cn/ 优三缔 官方网站&#xff1b; 点击【产品列表】→点击【查看更多】→选择自己需要的版本→点【开始使用】 点击【从Unity Hub下载】 以Windows为例&am…

240004】基于maven的java+ssm+mysql的房屋租赁系统的设计与实现

基于ssmmavenmysql的房屋租赁系统的设计与实现 1.项目描述2.运行环境3.项目截图4.源码获取 1.项目描述 该项目在原有的基础上进行了优化&#xff0c;包括新增了注册功能&#xff0c;房屋模糊查询功能&#xff0c;管理员和用户信息管理等功能&#xff0c;以及对网站界面进行了优…

NEEP-EN2-2023-Section5PartB

题目 个人答案 The chart depicts the outcomes of a survey conducted in a specific university regarding the acquisition of practical activity in class. The chart illustrates that learning knowledges accounts for 91.3 percent, which is the highest percentage…

WPF 控件

<div id"content_views" class"htmledit_views"><p id"main-toc"><strong>目录</strong></p> WPF基础控件 按钮控件&#xff1a; Button:按钮 RepeatButton:长按按钮 RadioButton:单选按钮 数据显示控件 Te…

系列1:基于Centos-8.6部署Kubernetes (1.24-1.30)

每日禅语 “木末芙蓉花&#xff0c;山中发红萼&#xff0c;涧户寂无人&#xff0c;纷纷开自落。​”这是王维的一首诗&#xff0c;名叫《辛夷坞》​。这首诗写的是在辛夷坞这个幽深的山谷里&#xff0c;辛夷花自开自落&#xff0c;平淡得很&#xff0c;既没有生的喜悦&#xff…

ESP8266 Ubuntu 安装

文章参考&#xff1a;https://blog.csdn.net/AUST_129/article/details/119406722文章浏览阅读1.8k次&#xff0c;点赞4次&#xff0c;收藏19次。参考&#xff1a;https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/get-started/linux-setup.htmlhttp://aicloud…

软件压力测试和负载测试有什么联系与区别?

在当今数字化时代&#xff0c;软件质量的重要性愈发凸显。在各种软件测试中&#xff0c;压力测试和负载测试都属于性能测试中的一种测试方法&#xff0c;那么这两者分别是什么?又有什么联系和区别呢? 一、压力测试和负载测试的定义   压力测试通常是指在特定的环境中&…

C# 异常处理 详解

总目录 前言 一、异常 1、定义 异常是在程序执行期间出现的问题。 C# 中的异常是对程序运行时出现的特殊情况的一种响应&#xff0c;比如尝试除以零。 异常&#xff1a;程序员必须控制和解决的问题。程序可以正常的运行&#xff0c;但是在运行的过程中出现了问题&#xff0c;…

类OCSP靶场-Kioptrix系列-Kioptrix Level 2

一、前情提要 二、实战打靶 1. 信息收集 1.1. 主机发现 1.2. 端口扫描 1.3.目录遍历 2.漏洞发现 2.1. 登录框测试 2.2. 发现命令执行 2.3 构造命令执行利用payload 3.提权 3.1. 搜索提权exp 3.2. 查看exp信息 3.3. Privilege Escalation的exp利用 exp_9542 一、前…

μC/OS-Ⅱ源码学习(6)---事件标志组

快速回顾 μC/OS-Ⅱ中的多任务 μC/OS-Ⅱ源码学习(1)---多任务系统的实现 μC/OS-Ⅱ源码学习(2)---多任务系统的实现(下) μC/OS-Ⅱ源码学习(3)---事件模型 μC/OS-Ⅱ源码学习(4)---信号量 μC/OS-Ⅱ源码学习(5)---消息队列 本文进一步解析事件模型中&#xff0c;事件标志…

学习maven(maven 项目模块化,继承,聚合)

前言 本篇博客的核心&#xff1a;理解maven 项目模块化&#xff0c;继承&#xff0c;聚合 的含义 maven 项目模块化 含义 maven项目模块化&#xff1a;使用maven 构建项目&#xff0c;管理项目的方式&#xff0c;我们可以将maven项目根据内在的关系拆分成很多个小项目【模块】…

电工电子技术实验:电压比较器及其应用电路

实验目的 1&#xff0e;了解电压比较器与运算放大器的性能区别&#xff1b; 2&#xff0e;掌握电压比较器的结构及特点&#xff1b; 3&#xff0e;掌握电压比较器电压传输特性的测试方法&#xff1b; 4&#xff0e;学习比较器在电路设计中的应用 实验原理 电压比较器是一…

3D相框案例讲解(详细)

前言 通过现阶段的学习&#xff0c;我们已经掌握了HTML&#xff0c;CSS和JS部分的相关知识点&#xff0c;现在让我们通过一篇案例&#xff0c;来巩固我们近期所学的知识点。 详细视频讲解戳这里 任务一 了解目标案例样式 1.1了解案例 3D相框 1.2 分析案例 首先我们看到一个…

C/C++代码性能优化技巧的书籍及资料

使用C/C开发的场景&#xff0c;大多对代码的执行的速度&#xff0c;实时性有较高的要求&#xff0c;像嵌入式系统的开发&#xff0c;资源还受限。在算力存储空间有限的MCU上写出简洁又高效的代码实际是一种艺术。软件工程师在代码设计上的这种差距&#xff0c;会反映在产品的性…

JAVA:建造者模式(Builder Pattern)的技术指南

1、简述 建造者模式(Builder Pattern)是一种创建型设计模式,它通过将对象的构造过程与表示分离,使得相同的构造过程可以创建不同的表示。建造者模式尤其适用于创建复杂对象的场景。 设计模式样例:https://gitee.com/lhdxhl/design-pattern-example.git 本文将详细介绍建…

软件集成测试内容和作用简析

在现代软件开发过程中&#xff0c;软件集成测试作为关键的一环&#xff0c;日益受到重视。特别是随着信息技术的快速发展&#xff0c;各类软件系统日益庞大复杂&#xff0c;如何确保系统不同模块的顺畅合作&#xff0c;成为了每个项目成功的重要基础。集成测试是指在软件开发过…