2025.1.15——1200

news/2025/1/16 12:30:10/文章来源:https://www.cnblogs.com/jkkk/p/18674762

2025.1.15——1200


Q1. 1200

简单来说就是给定3个数组,每个数组选择一个数,三者下标不同,问三者和的最大值。

Winter holidays are coming up. They are going to last for \(n\) days.

During the holidays, Monocarp wants to try all of these activities exactly once with his friends:

  • go skiing;
  • watch a movie in a cinema;
  • play board games.

Monocarp knows that, on the \(i\)-th day, exactly \(a_i\) friends will join him for skiing, \(b_i\) friends will join him for a movie and \(c_i\) friends will join him for board games.

Monocarp also knows that he can't try more than one activity in a single day.

Thus, he asks you to help him choose three distinct days \(x, y, z\) in such a way that the total number of friends to join him for the activities (\(a_x + b_y + c_z\)) is maximized.
Input

The first line of each testcase contains a single integer \(n\) (\(3 \le n \le 10^5\)) — the duration of the winter holidays in days.

The second line contains \(n\) integers \(a_1, a_2, \dots, a_n\) (\(1 \le a_i \le 10^8\)) — the number of friends that will join Monocarp for skiing on the \(i\)-th day.

The third line contains \(n\) integers \(b_1, b_2, \dots, b_n\) (\(1 \le b_i \le 10^8\)) — the number of friends that will join Monocarp for a movie on the \(i\)-th day.

The fourth line contains \(n\) integers \(c_1, c_2, \dots, c_n\) (\(1 \le c_i \le 10^8\)) — the number of friends that will join Monocarp for board games on the \(i\)-th day.


Q2. 1200

You are given an array \(a_1, a_2, \dots, a_n\) of distinct positive integers. You have to do the following operation exactly once:

  • choose a positive integer \(k\);
  • for each \(i\) from \(1\) to \(n\), replace \(a_i\) with \(a_i \text{ mod } k^\dagger\).

Find a value of \(k\) such that \(1 \leq k \leq 10^{18}\) and the array \(a_1, a_2, \dots, a_n\) contains exactly \(2\) distinct values at the end of the operation. It can be shown that, under the constraints of the problem, at least one such \(k\) always exists. If there are multiple solutions, you can print any of them.

\(^\dagger\) \(a \text{ mod } b\) denotes the remainder after dividing \(a\) by \(b\). For example:

  • \(7 \text{ mod } 3=1\) since \(7 = 3 \cdot 2 + 1\)
  • \(15 \text{ mod } 4=3\) since \(15 = 4 \cdot 3 + 3\)
  • \(21 \text{ mod } 1=0\) since \(21 = 21 \cdot 1 + 0\)

Input

The first line of each test case contains a single integer \(n\) (\(2 \le n \le 100\)) — the length of the array \(a\).

The second line of each test case contains \(n\) integers \(a_1, a_2, \ldots, a_n\) (\(1 \le a_i \le 10^{17}\)) — the initial state of the array. It is guaranteed that all the \(a_i\) are distinct.


Q3. 1200

In Cyprus, the weather is pretty hot. Thus, Theofanis saw this as an opportunity to create an ice cream company.

He keeps the ice cream safe from other ice cream producers by locking it inside big storage rooms. However, he forgot the password. Luckily, the lock has a special feature for forgetful people!

It gives you a table \(M\) with \(n\) rows and \(n\) columns of non-negative integers, and to open the lock, you need to find an array \(a\) of \(n\) elements such that:

  • \(0 \le a_i < 2^{30}\), and
  • \(M_{i,j} = a_i | a_j\) for all \(i \neq j\), where \(|\) denotes the bitwise OR operation.

The lock has a bug, and sometimes it gives tables without any solutions. In that case, the ice cream will remain frozen for the rest of eternity.

Can you find an array to open the lock?


Q4. 1200

Kristina has a matrix of size \(n\) by \(n\), filled with lowercase Latin letters. The value of \(n\) is even.

She wants to change some characters so that her matrix becomes a perfect square. A matrix is called a perfect square if it remains unchanged when rotated \(90^\circ\) clockwise once.

Here is an example of rotating a matrix by \(90^\circ\):

In one operation, Kristina can choose any cell and replace its value with the next character in the alphabet. If the character is equal to "z", its value does not change.

Find the minimum number of operations required to make the matrix a perfect square.


Q5. 1200

Chaneka, a gamer kid, invented a new gaming controller called joyboard. Interestingly, the joyboard she invented can only be used to play one game.

The joyboard has a screen containing \(n+1\) slots numbered from \(1\) to \(n+1\) from left to right. The \(n+1\) slots are going to be filled with an array of non-negative integers \([a_1,a_2,a_3,\ldots,a_{n+1}]\). Chaneka, as the player, must assign \(a_{n+1}\) with an integer between \(0\) and \(m\) inclusive. Then, for each \(i\) from \(n\) to \(1\), the value of \(a_i\) will be equal to the remainder of dividing \(a_{i+1}\) (the adjacent value to the right) by \(i\). In other words, \(a_i = a_{i + 1} \bmod i\).

Chaneka wants it such that after every slot is assigned with an integer, there are exactly \(k\) distinct values in the entire screen (among all \(n+1\) slots). How many valid ways are there for assigning a non-negative integer into slot \(n+1\)?
Input

The only line of each test case contains three integers \(n\), \(m\), and \(k\) (\(1 \leq n \leq 10^9\); \(0 \leq m \leq 10^9\); \(1 \leq k \leq n+1\)) — there are \(n+1\) slots, the integer assigned in slot \(n+1\) must not be bigger than \(m\), and there should be exactly \(k\) distinct values.


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

  • 发现结论+发现充分性结论/二进制/取模+位运算/神秘题+发现结论/推坐标+数论/模拟结论。前3题被卡了,值得回味。


A1

  1. 卡了好久在想优化,感觉优化很麻烦。其实方向错了。
  2. 发现结论:可缩小范围,每个数组选择的范围只有三个数。
  3. 据说还有dp解法。

A2.

  1. 充分性:在所有数不相同条件下,在二进制之下,由低位到高位必然会存在两种值。

A3

  1. 位运算局部到整体:构造每一位,若 \(M\)\(0\)\(a_i\) \(a_j\) 必为 \(0\),否则使 \(a_i\) \(a_j\)\(1\)
  2. 是道神秘题,充分必要性我现在不能证明。 点击链接去洛谷吧

A4

  1. 发现结论:对应的四个位置绑定,都要变相同取最大值。
  2. 推出动态坐标即可。

A5

  1. 数论一下或模拟发现结论。

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

A1

#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(10);int T = 1;cin >> T;while (T--)_();return 0;
}void _()
{int n;cin >> n;vector<int> a(n), b(n), c(n);for (int &x : a)cin >> x;for (int &x : b)cin >> x;for (int &x : c)cin >> x;struct Node{int x, idx;};vector<Node> mx1, mx2, mx3;auto get = [](vector<int> &a, vector<Node> &mx){mx.assign(3, {-1, -1});for (int i = 0; i < a.size(); i++)if (a[i] > mx[0].x)mx[2] = mx[1], mx[1] = mx[0], mx[0] = {a[i], i};else if (a[i] > mx[1].x)mx[2] = mx[1], mx[1] = {a[i], i};else if (a[i] > mx[2].x)mx[2] = {a[i], i};};get(a, mx1);get(b, mx2);get(c, mx3);int res = 0;for (auto [va, ida] : mx1)for (auto [vb, idb] : mx2)for (auto [vc, idc] : mx3)if (ida - idb && ida - idc && idb - idc)res = max(res, va + vb + vc);cout << res << endl;
}

A2

#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(10);int T = 1;cin >> T;while (T--)_();return 0;
}void _()
{int n;cin >> n;vector<int> a(n);for (int &x : a)cin >> x;int bit = 0;auto check = [&](int bit){int two[2] = {};for (auto v : a)two[v >> bit & 1]++;return two[0] && two[1];};for (;; bit++)if (check(bit))break;cout << (1ll << bit + 1) << endl;
}

A3

#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(10);int T = 1;cin >> T;while (T--)_();return 0;
}void _()
{int n;cin >> n;vector<vector<int>> a(n + 1, vector<int>(n + 1));for (int i = 1; i <= n; i++)for (int j = 1; j <= n; j++)cin >> a[i][j];vector<int> res(n + 1, (1ll << 30) - 1);for (int i = 1; i <= n; i++)for (int j = i + 1; j <= n; j++)res[i] &= a[i][j], res[j] &= a[i][j];bool f = 1;for (int i = 1; i <= n; i++)for (int j = i + 1; j <= n; j++)if ((res[i] | res[j]) - a[i][j])f = 0;cout << (f ? "YES" : "NO") << endl;if (f)for (int i = 1; i <= n; i++)cout << res[i] << ' ';cout << endl;
}

A4

#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(10);int T = 1;cin >> T;while (T--)_();return 0;
}void _()
{int n;cin >> n;vector<string> a(n + 1);for (int i = 1; i <= n; i++){cin >> a[i];a[i] = " " + a[i];}int res = 0;auto get = [](char a, char b, char c, char d){int ans = 0;char mx = max({a, b, c, d});ans += abs(mx - a) + abs(mx - b) + abs(mx - c) + abs(mx - d);return ans;};for (int i = 1; i <= n >> 1; i++)for (int j = 1; j <= n >> 1; j++)res += get(a[i][j], a[n - i + 1][n - j + 1], a[n - j + 1][i], a[j][n - i + 1]);cout << res << endl;
}

A5

#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(10);int T = 1;cin >> T;while (T--)_();return 0;
}void _()
{int n, m, k;cin >> n >> m >> k;int res = 0;if (m > n)res = m - n + 1 - m / n;if (k == 1)res = 1;if (k == 2)res = m - res;if (k > 3)res = 0;cout << res << endl;
}

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

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

相关文章

【附源码】JAVA大学生竞赛管理系统源码+SpringBoot+VUE+前后端分离

学弟,学妹好,我是爱学习的学姐,今天带来一款优秀的项目:大学生竞赛管理系统 。 本文介绍了系统功能与部署安装步骤,如果您有任何问题,也请联系学姐,偶现在是经验丰富的程序员! 一. 系统演示 系统测试截图系统视频演示https://githubs.xyz/show/343.mp4二. 系统概述【 系…

Ubuntu升级Linux内核教程

本文作者CVE-柠檬i:https://www.cnblogs.com/CVE-Lemon 本文使用的方法是dpkg安装,目前版本为5.4.0-204,要升级成5.8.5版本下载 下载网站:https://kernel.ubuntu.com/mainline/ 在该网站下载deb包,选择自己想要升级的版本,这里是5.8.5https://kernel.ubuntu.com/mainline/…

psSign、random推导

入口:传递的参数值:sign函数 function() {var _0x36c5d3 = _0x79c1ce;let _0x479298 = arguments[_0x36c5d3(0x5a9, PHXL)] > 0x0 && void 0x0 !== arguments[0x0] ? arguments[0x0] : {};try {var _0x1a6f66;if (!_0x32d6a8[_0x36c5d3(0x4d7, l!Uo)][_0x36c5d3(…

渗透测试中如何反编译JAR

反编译是渗透测试中的重要环节之一。 通过反编译,我们可以得到程序的项目结构、相关资源以及配置的数据库等信息。 本文以常见SpringBoot项目为例,对其进行反编译。 Spring Boot 是一个基于 Spring 的框架,旨在简化 Spring 应用的配置和开发过程,通过自动配置和约定大于配置…

专项训练2

贪心专题 1. [NOIP2015 普及组] 推销员 link:https://www.luogu.com.cn/problem/P2672 思路跟正解大差不差,但想的有点复杂了。先把所有的按疲劳值排个序,(这样省却了找最大疲劳值的过程),然后只用考虑第x大的和后面距离+疲劳值最大值的比较即可(累了,不想写了) 2. Tw…

vue2子组件获取父组件的实例以及数据,vue2子组件获取父组件的数据

多个组件引入同一个js文件,实例化对象,数据不会错乱,再引入相同的组件,例如每个页面都需要引入到一个分页组件,然后分页组件需要获取各自父组件中的实例对象 通过 this.$parent 即可获取到父组件中的数据 所以在使用子组件时可以不用在组件上传入数据 公共js文件functi…

专利申请审批流程

依据专利法,发明专利申请的审批程序包括受理、初审、公布、实审以及授权五个阶段。实用新型或者外观设计专利申请在审批中不进行早期公布和实质审查,只有受理、初审和授权三个阶段。 发明、实用新型和外观设计专利的申请、审查流程图如下:

深入理解第二范式(2NF):提升数据库设计的有效性与灵活性

title: 深入理解第二范式(2NF):提升数据库设计的有效性与灵活性 date: 2025/1/16 updated: 2025/1/16 author: cmdragon excerpt: 数据库的规范化是确保数据完整性和消除数据冗余的关键过程。第二范式(2NF)是关系数据库设计中的重要概念,进一步建立在第一范式的基础之上…

【附源码】JAVA课程管理系统源码+SpringBoot+VUE+前后端分离

学弟,学妹好,我是爱学习的学姐,今天带来一款优秀的项目:课程管理系统 。 本文介绍了系统功能与部署安装步骤,如果您有任何问题,也请联系学姐,偶现在是经验丰富的程序员! 一. 系统演示 系统测试截图系统视频演示https://githubs.xyz/show/342.mp4二. 系统概述【 系统功能…

【YashanDB知识库】解压安装包时报错tar:Error is not recoverable

本文内容来自YashanDB官网,原文内容请见 https://www.yashandb.com/newsinfo/7919233.html?templateId=1718516 现象 解压安装时报如下错误:、分析过程 1、检查解包命令是否正确 tar --help 2、查询CPU类型(arm/x86,32bit/64bit)是否与包匹配 lscpu3、检查MD5值, md5sum 再下…

多校区管理难题:管理工具的高效解决方案

一、连锁培训机构的管理挑战 多校区数据同步难题连锁机构需要实时掌握各校区的学员、教师、财务等数据,而传统的手工记录或独立系统难以满足这一需求。 跨校区资源协作障碍教室、师资和课程安排在不同校区间分配时,容易产生冲突或资源浪费。 信息孤岛现象各校区独立运作的模式…

宝塔面板无法访问怎么办?

宝塔面板是许多用户管理和维护服务器的重要工具。当遇到宝塔面板无法访问的情况时,可能是由于多种原因引起的。以下是一些常见问题及其解决方案: 一、检查网络连接本地网络环境:确保您的本地网络连接正常,尝试访问其他网站以确认是否是网络问题。服务器网络状态:登录云服务…