02 2023 档案
摘要:裁剪序列 给定一个长度为 $N$ 的序列 $A$,要求把该序列分成若干段,在满足“每段中所有数的和”不超过 $M$ 的前提下,让“每段中所有数的最大值”之和最小。 试计算这个最小值。 输入格式 第一行包含两个整数 $N$ 和 $M$。 第二行包含 $N$ 个整数,表示完整的序列 $A$。 输出格式
阅读全文
摘要:Devu和鲜花 Devu 有 $N$ 个盒子,第 $i$ 个盒子中有 $A_i$ 枝花。 同一个盒子内的花颜色相同,不同盒子内的花颜色不同。 Devu 要从这些盒子中选出 $M$ 枝花组成一束,求共有多少种方案。 若两束花每种颜色的花的数量都相同,则认为这两束花是相同的方案。 结果需对 $10^9+
阅读全文
摘要:构造新矩阵 给定一个 $m$ 行 $n$ 列的整数矩阵,行编号 $1 \sim m$,列编号 $1 \sim n$。 其中,第 $i$ 行第 $j$ 列的元素为 $p_{ij}$。 你可以任意抽取其中不超过 $n−1$ 行元素,这些元素之间保持同一行列关系不变,构成一个新矩阵。 构成新矩阵后,我们可
阅读全文
摘要:The Number of Good Subsets You are given an integer array nums . We call a subset of nums good if its product can be represented as a product of one o
阅读全文
摘要:Count the Number of Square-Free Subsets You are given a positive integer 0-indexed array nums . A subset of the array nums is square-free if the produ
阅读全文
摘要:Handling Sum Queries After Update You are given two 0-indexed arrays nums1 and nums2 and a 2D array queries of queries. There are three types of queri
阅读全文
摘要:D. Triangle Coloring You are given an undirected graph consisting of $n$ vertices and $n$ edges, where $n$ is divisible by $6$. Each edge has a weight
阅读全文
摘要:约数之和 假设现在有两个自然数 $A$ 和 $B$,$S$ 是 $A^B$ 的所有约数之和。 请你求出 $S \bmod 9901$ 的值是多少。 输入格式 在一行中输入用空格隔开的两个整数 $A$ 和 $B$。 输出格式 输出一个整数,代表 $S \bmod 9901$ 的值。 数据范围 $0 \
阅读全文
摘要:台阶-Nim游戏 现在,有一个 $n$ 级台阶的楼梯,每级台阶上都有若干个石子,其中第 $i$ 级台阶上有 $a_i$ 个石子$(i \geq 1)$。 两位玩家轮流操作,每次操作可以从任意一级台阶上拿若干个石子放到下一级台阶中(不能不拿)。 已经拿到地面上的石子不能再拿,最后无法进行操作的人视为失
阅读全文
摘要:Nim游戏 给定 $n$ 堆石子,两位玩家轮流操作,每次操作可以从任意一堆石子中拿走任意数量的石子(可以拿完,但不能不拿),最后无法进行操作的人视为失败。 问如果两人都采用最优策略,先手是否必胜。 输入格式 第一行包含整数 $n$。 第二行包含 $n$ 个数字,其中第 $i$ 个数字表示第 $i$
阅读全文
摘要:能被整除的数 给定一个整数 $n$ 和 $m$ 个不同的质数 $p_1,p_2, \ldots ,p_m$。 请你求出 $1 \sim n$ 中能被 $p_1,p_2, \ldots ,p_m$ 中的至少一个数整除的整数有多少个。 输入格式 第一行包含整数 $n$ 和 $m$。 第二行包含 $m$
阅读全文
摘要:D. Moscow Gorillas In winter, the inhabitants of the Moscow Zoo are very bored, in particular, it concerns gorillas. You decided to entertain them and
阅读全文
摘要:B. Fedya and Array For his birthday recently Fedya was given an array $a$ of $n$ integers arranged in a circle, For each pair of neighboring numbers (
阅读全文
摘要:Subsequence With the Minimum Score You are given two strings $s$ and $t$ . You are allowed to remove any number of characters from the string t. The s
阅读全文
摘要:Substring XOR Queries You are given a binary string s , and a 2D integer array queries where queries[i] = [firsti, secondi] . For the ith query, find
阅读全文
摘要:Count the Number of Fair Pairs Given a 0-indexed integer array nums of size n and two integers lower and upper , return the number of fair pairs. A pa
阅读全文
摘要:找数字 给定一个正整数 $m$ 和一个非负整数 $s$。 请你找到长度为 $m$ 且各位数字之和为 $s$ 的最小和最大非负整数。 要求所求非负整数不得包含前导零。 输入格式 共一行,两个整数 $m,s$。 输出格式 在一行内输出满足条件的最小和最大非负整数。 如果无解,则输出 -1 -1。 数据范
阅读全文
摘要:B. Jumbo Extra Cheese 2 Pak Chanek has $n$ two-dimensional slices of cheese. The $i$-th slice of cheese can be represented as a rectangle of dimension
阅读全文
摘要:D. Moving Dots We play a game with $n$ dots on a number line. The initial coordinate of the $i$-th dot is $x_i$. These coordinates are distinct. Every
阅读全文
摘要:B. Sum of Two Numbers The sum of digits of a non-negative integer $a$ is the result of summing up its digits together when written in the decimal syst
阅读全文
摘要:E. Sum Over Zero You are given an array $a_1, a_2, \ldots, a_n$ of $n$ integers. Consider $S$ as a set of segments satisfying the following conditions
阅读全文
摘要:D. Lucky Permutation You are given a permutation$^\dagger$ $p$ of length $n$. In one operation, you can choose two indices $1 \le i < j \le n$ and swa
阅读全文
摘要:E. Monsters (hard version) This is the hard version of the problem. In this version, you need to find the answer for every prefix of the monster array
阅读全文
摘要:Disconnect Path in a Binary Matrix by at Most One Flip You are given a 0-indexed $m \times n$ binary matrix grid . You can move from a cell (row, col)
阅读全文
摘要:Maximize Win From Two Segments There are some prizes on the X-axis. You are given an integer array prizePositions that is sorted in non-decreasing ord
阅读全文
摘要:G2. Teleporters (Hard Version) The only difference between the easy and hard versions are the locations you can teleport to. Consider the points $0,1,
阅读全文
摘要:E. Negatives and Positives Given an array $a$ consisting of $n$ elements, find the maximum possible sum the array can have after performing the follow
阅读全文
摘要:Minimum Cost to Make Array Equal You are given two 0-indexed arrays nums and cost consisting each of $n$ positive integers. You can do the following o
阅读全文
摘要:Count Increasing Quadruplets Given a 0-indexed integer array nums of size $n$ containing all numbers from $1$ to $n$, return the number of increasing
阅读全文
摘要:方程的解 佳佳碰到了一个难题,请你来帮忙解决。 对于不定方程 $a_1 + a_2+ \ldots + a_{k−1} + a_k = g(x)$,其中 $k \geq 1$ 且 $k \in N^{*}$,$x$ 是正整数,$g(x) = x^{x} \bmod 1000$(即 $x^{x}$ 除
阅读全文
摘要:Put Marbles in Bags You have k bags. You are given a 0-indexed integer array weights where weights[i] is the weight of the ith marble. You are also gi
阅读全文
摘要:牡牛和牝牛 约翰要带 $N$ 只牛去参加集会里的展示活动,这些牛可以是牡牛,也可以是牝牛。 牛们要站成一排,但是牡牛是好斗的,为了避免牡牛闹出乱子,约翰决定任意两只牡牛之间至少要有 $K$ 只牝牛。 请计算一共有多少种排队的方法,所有牡牛可以看成是相同的,所有牝牛也一样,答案对 $5000011$
阅读全文