01 2023 档案
摘要:C. Remove the Bracket RSJ has a sequence $a$ of $n$ integers $a_1,a_2, \ldots, a_n$ and an integer $s$. For each of $a_2,a_3, \ldots, a_{n-1}$, he cho
阅读全文
摘要:F. Timofey and Black-White Tree Timofey came to a famous summer school and found a tree on $n$ vertices. A tree is a connected undirected graph withou
阅读全文
摘要:斐波那契前 n 项和 大家都知道 Fibonacci 数列吧,$f_1=1,f_2=1,f_3=2,f_4=3, \ldots ,f_n=f_{n−1}+f_{n−2}$。 现在问题很简单,输入 $n$ 和 $m$,求 $f_n$ 的前 $n$ 项和 $S_n \bmod m$。 输入格式 共一行,
阅读全文
摘要:最幸运的数字 $8$ 是中国的幸运数字,如果一个数字的每一位都由 $8$ 构成则该数字被称作是幸运数字。 现在给定一个正整数 $L$,请问至少多少个 $8$ 连在一起组成的正整数(即最小幸运数字)是 $L$ 的倍数。 输入格式 输入包含多组测试用例。 每组测试用例占一行,包含一个整数 $L$。 当输
阅读全文
摘要:B. GCD Partition While at Kira's house, Josuke saw a piece of paper on the table with a task written on it. The task sounded as follows. There is an a
阅读全文
摘要:D. Fixed Prefix Permutations You are given $n$ permutations $a_1, a_2, \dots, a_n$, each of length $m$. Recall that a permutation of length $m$ is a s
阅读全文
摘要:Rank Transform of a Matrix Given an m x n matrix , return a new matrix answer where answer[row][col] is the rank of matrix[row][col] . The rank is an
阅读全文
摘要:Minimum Cost to Split an Array You are given an integer array nums and an integer $k$. Split the array into some number of non-empty subarrays. The co
阅读全文
摘要:B. Emordnilap A permutation of length $n$ is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2,3,1,5,4
阅读全文
摘要:C. Quiz Master A school has to decide on its team for an international quiz. There are $n$ students in the school. We can describe the students using
阅读全文
摘要:最大公约数 给定整数 $N$,求 $1 \leq x,y \leq N$ 且 $\text{GCD}(x,y)$ 为素数的数对 $(x,y)$ 有多少对。 $\text{GCD}(x,y)$ 即求 $x$,$y$ 的最大公约数。 输入格式 输入一个整数 $N$。 输出格式 输出一个整数,表示满足条件
阅读全文
摘要:可见的点 在一个平面直角坐标系的第一象限内,如果一个点 $(x,y)$ 与原点 $(0,0)$ 的连线中没有通过其他任何点,则称该点在原点处是可见的。 例如,点 $(4,2)$ 就是不可见的,因为它与原点的连线会通过点 $(2,1)$。 部分可见点与原点的连线如下图所示: 编写一个程序,计算给定整数
阅读全文
摘要:Hankson的趣味题 Hanks 博士是 BT(Bio-Tech,生物技术)领域的知名专家,他的儿子名叫 Hankson。 现在,刚刚放学回家的 Hankson 正在思考一个有趣的问题。 今天在课堂上,老师讲解了如何求两个正整数 $c_1$ 和 $c_2$ 的最大公约数和最小公倍数。 现在 Han
阅读全文
摘要:樱花 给定一个整数 $n$,求有多少正整数数对 $(x,y)$ 满足 $\frac{1}{x}+\frac{1}{y}=\frac{1}{n!}$。 输入格式 一个整数 $n$。 输出格式 一个整数,表示满足条件的数对数量。 答案对 ${10}^9+7$ 取模。 数据范围 $ 1 \leq n \l
阅读全文
摘要:质数距离 给定两个整数 $L$ 和 $U$,你需要在闭区间 $[L,U]$ 内找到距离最接近的两个相邻质数 $C_1$ 和 $C_2$(即 $C_2−C_1$ 是最小的),如果存在相同距离的其他相邻质数对,则输出第一对。 同时,你还需要找到距离最远的两个相邻质数 $D_1$ 和 $D_2$(即 $D
阅读全文
摘要:D. Many Perfect Squares You are given a set $a_1, a_2, \ldots, a_n$ of distinct positive integers. We define the squareness of an integer $x$ as the n
阅读全文
摘要:C. Equal Frequencies Let's call a string balanced if all characters that are present in it appear the same number of times. For example, "coder", "app
阅读全文
摘要:Difference Between Maximum and Minimum Price Sum There exists an undirected and initially unrooted tree with $n$ nodes indexed from $0$ to $n - 1$. Yo
阅读全文
摘要:D. Friendly Spiders Mars is home to an unusual species of spiders — Binary spiders. Right now, Martian scientists are observing a colony of $n$ spider
阅读全文
摘要:C. Interesting Sequence Petya and his friend, robot Petya++, like to solve exciting math problems. One day Petya++ came up with the numbers $n$ and $x
阅读全文
摘要:最大价值 已知,小写字母 $a \sim z$ 的价值分别为 $w_a,w_b, \ldots, w_z$。 对于一个由小写字母构成的长度为 $l$ 的字符串 $S=s_{1} s_{2} \ldots s_{l}$,其价值为 $w_{s1} \times 1 + w_{s2} \times 2 +
阅读全文
摘要:B. Gardener and the Array The gardener Kazimir Kazimirovich has an array of $n$ integers $c_1, c_2, \dots, c_n$. He wants to check if there are two di
阅读全文
摘要:等差数列 给定一个长度为 $n$ 的正整数数列 $a_1,a_2, \ldots, a_n$ 和一个正整数 $k$。 你可以对数列进行以下两种操作: + i x ,增加操作,将 $a_i$ 的值增加 $x$($x \geq 1$)。- i x ,减少操作,将 $a_i$ 的值减少 $x$($x \g
阅读全文
摘要:Maximize the Minimum Powered City You are given a 0-indexed integer array stations of length $n$, where stations[i] represents the number of power sta
阅读全文
摘要:Number of Great Partitions You are given an array nums consisting of positive integers and an integer k . Partition the array into two ordered groups
阅读全文
摘要:Count Pairs With XOR in a Range Given a (0-indexed) integer array nums and two integers low and high , return the number of nice pairs. A nice pair is
阅读全文
摘要:Maximum Number of Points From Grid Queries You are given an $m \times n$ integer matrix grid and an array queries of size $k$. Find an array answer of
阅读全文
摘要:Frog Jump II You are given a 0-indexed integer array stones sorted in strictly increasing order representing the positions of stones in a river. A fro
阅读全文
摘要:技能升级 小蓝最近正在玩一款 $RPG$ 游戏。 他的角色一共有 $N$ 个可以加攻击力的技能。 其中第 $i$ 个技能首次升级可以提升 $A_i$ 点攻击力,以后每次升级增加的点数都会减少 $B_i$。 $\left\lceil \frac{A_i}{B_i} \right\rceil$(上取整)
阅读全文
摘要:选数异或 给定一个长度为 $n$ 的数列 $A_1,A_2,\ldots,A_n$ 和一个非负整数 $x$,给定 $m$ 次查询,每次询问能否从某个区间 $[l,r]$ 中选择两个下标不同的数使得他们的异或等于 $x$。 输入格式 输入的第一行包含三个整数 $n,m,x$。 第二行包含 $n$ 个整
阅读全文
摘要:上课睡觉 有 $N$ 堆石子,每堆的石子数量分别为 $a_1,a_2, \ldots, a_N$。 你可以对石子堆进行合并操作,将两个相邻的石子堆合并为一个石子堆,例如,如果 $a=[1,2,3,4,5]$,合并第 $2,3$ 堆石子,则石子堆集合变为 $a=[1,5,4,5]$。 我们希望通过尽可
阅读全文