CUGB2023春前6周训练总结

第一周


Fedya and Array

CodeForces - 1793B

题目描述

有一个 n 个元素的序列 a,元素首尾相连排成圆环,任意两个相邻元素间差的绝对值等于 1。定义一个局部最小值为同时小于左右两个相邻元素的元素值,一个局部最大值为同时大于左右两个相邻元素的元素值。

注意,元素 a n a_n an和元素 a 1 a_1 a1是相邻元素。

给定序列 a 中所有局部最大值的和以及序列 a 中所有局部最小值的和,请还原出元素个数最少的数组 a。


Dora and Search

CodeForces - 1793C

题目描述

给定一个长度为n的排列a,问是否存在正整数 l,r 使得 a l a_l al, a r a_r ar均不为 a l − r a_{l-r} alr中的最大值或最小值。


Convex Quadrilateral

AtCoder - abc266_c

题目描述

输入平面直角坐标系内四个点 A,B,C,D 的坐标,判断四边形 ABCD (四条边分别为 AB,BC,CD,DA)是否为凸四边形。

题目保证两组对边(指这两条线段)均不相交。


Snuke Panic (1D)

AtCoder - abc266_d

题目描述

高桥君在数轴上挖了 5 5 5 个坑,坐标为 0 , 1 , 2 , 3 , 4 0,1,2,3,4 0,1,2,3,4。一开始他在 0 0 0 位置,每秒最多移动 1 1 1 单位。

现有 n n n 条 Snuke,第 i i i 条大小为 A i A_i Ai,在第 T i T_i Ti 时刻出现在坐标为 X i X_i Xi 的坑。请注意出现仅发生在瞬间,下一时刻消失。

高桥君能抓到第 i i i 条 Snuke 当且仅当某时刻他在第 T i T_i Ti 时刻出现在 X i X_i Xi。请计算他抓到的 Snuke 总大小最大值。


Throwing the Die

AtCoder - abc266_e

题目描述

你有一个普通均匀的正方体骰子,六个面写有 1 , 2 , 3 , 4 , 5 , 6 1,2,3,4,5,6 1,2,3,4,5,6。你在玩一个游戏,每次丢骰子之后,你可以:

  • 如果这是你的第 N N N 次投掷,那么你应当结束游戏。
  • 否则你可以选择重新投,或者结束游戏。

给定 N N N,计算如果你希望最后一次投掷时朝上面的期望最大,那么这个期望是多少。


Well-defined Path Queries on a Namori

AtCoder - abc266_f

题目描述

给定一张有 N N N 个点、 N N N 条边的简单连通无向图和 Q Q Q 次询问,对于每次询问,给定 x i , y i x_i,y_i xi,yi,表示两点的编号,请你回答第 x i x_i xi 个点和第 y i y_i yi 个点之间是否有且仅有一条简单路径。

  • 什么是简单路径?

如果路径上的各顶点均不重复,则称这样的路径为简单路径。


Yet Another RGB Sequence

AtCoder - abc266_g

题目描述

求符合要求的字符串个数,对 998244353 998244353 998244353 取余。

满足要求的字符串 s s s 具备以下特性:

  1. s s s 由 r、g、b 构成。

  2. s s s 中有 R R R 个 r, G G G 个 g, B B B 个 b, k k k 个 rg。


2-Letter Strings

CodeForces - 1669E

题目描述

你被给予了 n n n个长度为2的字符串,每个含有从 a a a k k k的小写字母。找出所有对 ( i , j ) (i,j) (i,j)使得 i < j i<j i<j并且第 i i i个字符串和第 j j j个字符串刚好有1个字符不同。

换句话来说,找到所有的数字对 ( i , j ) ( i < j ) (i,j)(i<j) (i,j)(i<j)使得第 i i i个字符串与第 j j j个字符串有唯一一个数字 p ( 1 ≤ p ≤ 2 ) p(1 \leq p \leq 2) p(1p2)使得 s i p ≠ s j p s_{i_p}\neq s_{j_p} sip=sjp

答案可能超出32位数的范围,所以你在使用c++时应该使用long long等64位变量类型来存储数据避免溢出


Eating Candies

CodeForces - 1669F

题目描述

n n n 个糖果从左往右放在桌子上, A l i c e Alice Alice B o b Bob Bob 吃糖果, A l i c e Alice Alice可以从左边开始吃, B o b Bob Bob可以从右边开始吃,他们需要连续吃,不能跳过任何一颗糖果,如果 A l i c e Alice Alice 吃掉了糖果, B o b Bob Bob 就不能吃,反之亦然,他们的目标是吃到等重的糖果。


Fall Down

CodeForces - 1669G

题目描述

有一个 n × m n\times m n×m 的网格( 1 ≤ n , m ≤ 50 1 \leq n, m \leq 50 1n,m50),其中每个格子上有三种情况:

  1. ’ o ’ 字符:此块为一个石子
  2. ’ * ’ 字符:此块为障碍物,石子不能通过。
  3. ’ . ’ 字符:此块为空,石子可以通过。

每块石子回往下落,直到它落在了网格最下面一行、障碍物的上面一格或已落下的石子上面一格

给出原式网格,求石子落下后的网格。


Maximal AND

CodeForces - 1669H

题目描述

AND \text{AND} AND 表示按位与, OR \text{OR} OR 表示按位或。

你有一个长度为 n n n 的数组 a a a 和一个非负整数 k k k 。你可以在 a a a 数组上做以下操作:

  • 选出一个下标 i i i ( 1 ≤ i ≤ n 1\le i\le n 1in),将 a i a_i ai 替换为 a i  OR  2 j a_i \text{ OR }2^j ai OR 2j ( 0 ≤ j ≤ 30 0\le j\le 30 0j30)。也就是说将二进制下的 a i a_i ai 的第 j j j 位赋为 1 1 1

最多做 k k k 次操作。

输出操作后 a 1  AND  a 2  AND … AND  a n a_1\text{ AND }a_2\text{ AND}\dots\text{AND }a_n a1 AND a2 ANDAND an 的最大值。


第二周


LIS or Reverse LIS?

CodeForces - 1682C

题目描述

设一个长为 n n n 的整数序列 a a a { a 1 , a 2 , a 3 , ⋯   , a n } \{a_1,a_2,a_3,\cdots,a_n\} {a1,a2,a3,,an},那么 a ′ a' a 表示 { a n , a n − 1 , a n − 2 , ⋯   , a 1 } \{a_n,a_{n-1},a_{n-2},\cdots,a_1\} {an,an1,an2,,a1} LIS ⁡ ( a ) \operatorname{LIS}(a) LIS(a) 表示 a a a 的最长严格上升子序列的长度。

现在给定 a a a 数组,请你将 a a a 数组重新排列,使得重排后的 min ⁡ ( LIS ⁡ ( a ) , LIS ⁡ ( a ′ ) ) \min(\operatorname{LIS}(a),\operatorname{LIS}(a')) min(LIS(a),LIS(a)) 最大。

输入 t t t 组数据,每组数据先输入 n n n ,然后输入 n n n 个整数,所有 n n n 之和不超过 2 × 1 0 5 2 \times 10^5 2×105

输出 t t t 行,每行一组数据的答案,按输入顺序输出。


Settlement of Guinea Pigs

CodeForces - 1802B

题目描述

Dasha 很喜欢豚鼠,她在 n n n 天内要不是买豚鼠,要不是请医生来看豚鼠。

Dasha 和宠物店都无法分辨豚鼠的性别(思考人生),只能在医生来查看豚鼠的时候为这些豚鼠做性别鉴定。

为了豚鼠,Dasha 打算给它们买一些笼子,但宠物店里卖的笼子只能放最多 2 2 2 只豚鼠。由于她不想让她的豚鼠遭受道德伤害,一个笼子里只能放同一种性别的豚鼠。

求 Dasha 最少需要买多少个笼子。


第三周


聚会

LibreOJ - 10136

题目描述

Y 岛风景美丽宜人,气候温和,物产丰富。Y 岛上有 N 个城市,有 N-1 条城市间的道路连接着它们。每一条道路都连接某两个城市。幸运的是,小可可通过这些道路可以走遍 Y 岛的所有城市。神奇的是,乘车经过每条道路所需要的费用都是一样的。

小可可,小卡卡和小 YY 经常想聚会,每次聚会,他们都会选择一个城市,使得三个人到达这个城市的总费用最小。

由于他们计划中还会有很多次聚会,每次都选择一个地点是很烦人的事情,所以他们决定把这件事情交给你来完成。他们会提供给你地图以及若干次聚会前他们所处的位置,希望你为他们的每一次聚会选择一个合适的地点。


跳跳棋

LibreOJ - 10137

题目描述

跳跳棋是在一条数轴上进行的。棋子只能摆在整点上。每个点不能摆超过一个棋子。我们用跳跳棋来做一个简单的游戏:棋盘上有三颗棋子,分别在 a,b,c 这三个位置。我们要通过最少的跳动把他们的位置移动成 x,y,z(注意:棋子是没有区别的)。

跳动的规则很简单,任意选一颗棋子,对一颗中轴棋子跳动。跳动后两颗棋子距离不变。一次只允许跳过一颗棋子。

写一个程序,首先判断是否可以完成任务。如果可以,输出最少需要的跳动次数。
在这里插入图片描述


Increase and Copy

CodeForces - 1426C

题目描述

初始给你一个元素 1 1 1 ,每次操作你可以选择让一个元素 + 1 +1 +1 或者复制一个元素.

求最少需要多少次操作使其总和不小于 n n n .


Two Permutations

HDU - 7173

题目描述

There are two permutations P1,P2,…,Pn, Q1,Q2,…,Qn and a sequence R. Initially, R is empty. While at least one of P and Q is non-empty, you need to choose a non-empty array (P or Q), pop its leftmost element, and attach it to the right end of R. Finally, you will get a sequence R of length 2n.

You will be given a sequence S of length 2n, please count the number of possible ways to merge P and Q into R such that R=S. Two ways are considered different if and only if you choose the element from different arrays in a step.


神、上帝以及老天爷

HDU - 2048

题目描述

HDU 2006’10 ACM contest的颁奖晚会隆重开始了!
为了活跃气氛,组织者举行了一个别开生面、奖品丰厚的抽奖活动,这个活动的具体要求是这样的:

首先,所有参加晚会的人员都将一张写有自己名字的字条放入抽奖箱中;
然后,待所有字条加入完毕,每人从箱中取一个字条;
最后,如果取得的字条上写的就是自己的名字,那么“恭喜你,中奖了!”

大家可以想象一下当时的气氛之热烈,毕竟中奖者的奖品是大家梦寐以求的Twins签名照呀!不过,正如所有试图设计的喜剧往往以悲剧结尾,这次抽奖活动最后竟然没有一个人中奖!

我的神、上帝以及老天爷呀,怎么会这样呢?

不过,先不要激动,现在问题来了,你能计算一下发生这种情况的概率吗?

不会算?难道你也想以悲剧结尾?!


第四周


Mex Master

CodeForces - 1806B

题目描述

给定长度为 n n n 的序列 a a a,规定 a a a 的权值为 mex { a 1 + a 2 , a 2 + a 3 , ⋯   , a n − 1 + a n } \text{mex}\{a_1+a_2,a_2+a_3,\cdots,a_{n-1}+a_n\} mex{a1+a2,a2+a3,,an1+an} mex \text{mex} mex 是指一个非负整数序列中最小的未在序列中出现的整数)。现在 a a a 可以任意排列,求 a a a 的最小权值。


Buying gifts

CodeForces - 1801B

题目描述

n n n 个商店,在第 i i i 个商店会进行下面两个操作之一:

  • 为朋友 A 买礼物,花费 a i a_i ai 元。
  • 为朋友 B 买礼物,花费 b i b_i bi 元。

求在每个商店进行过以上操作后,朋友 A 和 B 获得的礼物中的最大价值之差的最小值。

t t t 组测试数据。

数据范围: 1 ≤ t ≤ 1000 1\le t\le1000 1t1000 2 ≤ n ≤ 5 × 1 0 5 2\le n\le5\times 10^5 2n5×105 0 ≤ a i , b i ≤ 1 0 9 0\le a_i, b_i\le 10^9 0ai,bi109


Georgia and Bob

POJ - 1704

题目描述

Georgia and Bob decide to play a self-invented game. They draw a row of grids on paper, number the grids from left to right by 1, 2, 3, …, and place N chessmen on different grids, as shown in the following figure for example:
在这里插入图片描述
Georgia and Bob move the chessmen in turn. Every time a player will choose a chessman, and move it to the left without going over any other chessmen or across the left edge. The player can freely choose number of steps the chessman moves, with the constraint that the chessman must be moved at least ONE step and one grid can at most contains ONE single chessman. The player who cannot make a move loses the game.

Georgia always plays first since “Lady first”. Suppose that Georgia and Bob both do their best in the game, i.e., if one of them knows a way to win the game, he or she will be able to carry it out.

Given the initial positions of the n chessmen, can you predict who will finally win the game?


Bank

AtCoder - abc294_d

题目描述

给定数组 a a a 满足 a i = i a_i=i ai=i 和空数组 b b b,要求支持 3 3 3 种操作:

  1. 删除 a a a 中最小的元素,并将其加入 b b b 数组。
  2. 删除 b b b 中值为 x x x 的元素,保证存在。
  3. 输出 b b b 中的最小值。

数组长度为 n n n,有 m m m 次询问, n , m ≤ 5 × 1 0 5 n, m\le 5\times 10^5 n,m5×105


2xN Grid

AtCoder - abc294_e

题目描述

现在有两个长度为 L L L 的序列 a , b a,b a,b,找出有多少个下标 i i i 满足 a i = b i ( 1 ≤ i ≤ L ) a_i=b_i(1\leq i\leq L) ai=bi(1iL)

由于 L L L 十分地大,因此 a a a 被体现为一个长度为 N 1 N_1 N1 的二元组序列。下面是二元组序列的生成方式:

  • 对于所有 a a a 序列中的 a i ≠ a i + 1 a_i\neq a_{i+1} ai=ai+1,我们在 ( i , i + 1 ) (i,i+1) (i,i+1) 中间切割一次。
  • 最后 a a a 序列会被切割成 N 1 N_1 N1 块,每一块都是由 l i l_i li 个相同的数 x i x_i xi 组成的。我们将每一块表示成一个二元组 ( x i , l i ) (x_i,l_i) (xi,li),从左至右拼接起来即可得到一个长度为 N 1 N_1 N1 的二元组序列。

同理, b b b 被体现为一个长度为 N 2 N_2 N2 的二元组序列。

给出 L , N 1 , N 2 L,N_1,N_2 L,N1,N2 以及两个二元组序列,解决本题开头的问题。


Sugar Water 2

AtCoder - abc294_f

题目描述

高橋君有 N N N 瓶糖水,青木君有 M M M 瓶糖水。

高橋君的第 i i i 瓶糖水有 A i A_i Ai 份糖 B i B_i Bi 份水。

青木君的第 i i i 瓶糖水有 C i C_i Ci 份糖 D i D_i Di 份水。

将两人的糖水各选一瓶混合有 N M NM NM 种可能,求其中浓度第 k k k 大的糖水浓度是多少。

x x x 份糖和 y y y 份水的糖水浓度是 100 x x + y % \dfrac{100x}{x+y}\% x+y100x%


Make Takahashi Happy

AtCoder - abc293_c

题目描述

There is a grid with H horizontal rows and W vertical columns. For two integers i and j such that 1≤i≤H and 1≤j≤W, the square at the i-th row from the top and j-th column from the left (which we denote by (i,j)) has an integer A i , j A_{i,j} Ai,j written on it.

Takahashi is currently at (1,1). From now on, he repeats moving to an adjacent square to the right of or below his current square until he reaches (H,W). When he makes a move, he is not allowed to go outside the grid.

Takahashi will be happy if the integers written on the squares he visits (including initial (1,1) and final (H,W)) are distinct. Find the number of his possible paths that make him happy.


Tying Rope

AtCoder - abc293_d

题目描述

n n n 条绳子,每个绳子有两端,用字母 R 和 B 表示。有 m m m 个操作,将两条绳子各自的一端(给定)连接,保证不重复、不自己连接。最后输出两个整数,第一个代表联通的绳子中形成环的数量,第二个是没有形成环的,单独的绳子也算。


Geometric Progression

AtCoder - abc293_e

题目描述

给定正整数 A , X , M A,X,M A,X,M,求 ∑ i = 0 X − 1 A i \displaystyle \sum_{i=0}^{X-1}A^i i=0X1Ai,对 M M M 取模。

  • 1 ≤ A , M ≤ 1 0 9 1\leq A,M\leq 10^9 1A,M109
  • 1 ≤ X ≤ 1 0 12 1\leq X\leq 10^{12} 1X1012

Zero or One

AtCoder - abc293_f

题目描述

T T T 组数据,每组一个正整数 n n n,保证 2 ≤ n ≤ 1 0 18 2\leq n \leq 10^{18} 2n1018 ,对于每个 n n n 求满足条件的 b b b 的个数,使得 n n n b b b 进制表示只包含 0 0 0 1 1 1


Triple Index

AtCoder - abc293_g

题目描述

给定长度为 N N N 的数列 a 1 , a 2 , ⋯   , a N a_1,a_2,\cdots,a_N a1,a2,,aN

q q q 组询问,每组询问给定 l , r l,r l,r 1 ≤ l ≤ r ≤ n 1\le l\le r \le n 1lrn,问存在多少个三元组 ( i , j , k ) (i,j,k) (i,j,k),使得 l ≤ i < j < k ≤ r l\le i < j<k\le r li<j<kr a i = a j = a k a_i=a_j=a_k ai=aj=ak


第五周


Points on Plane

CodeForces - 1809B

题目描述

You are given a two-dimensional plane, and you need to place n n n chips on it.

You can place a chip only at a point with integer coordinates. The cost of placing a chip at the point ( x , y ) (x, y) (x,y) is equal to ∣ x ∣ + ∣ y ∣ |x| + |y| x+y (where ∣ a ∣ |a| a is the absolute value of a a a ).

The cost of placing $ n $ chips is equal to the maximum among the costs of each chip.

You need to place n n n chips on the plane in such a way that the Euclidean distance between each pair of chips is strictly greater than 1 1 1 , and the cost is the minimum possible.


Sum on Subarrays

CodeForces - 1809C

题目描述

给定两个正整数 n n n k k k,构造一个长度为 n n n 的序列 a a a 满足:

  • − 1000 ≤ a i ≤ 1000 -1000\le a_i\le 1000 1000ai1000
  • 序列有恰好 k k k 个子串的和为正数
  • 剩余 n ( n + 1 ) 2 − k \frac{n(n+1)}2-k 2n(n+1)k 个子串的和都是负数

你只需要输出任意一组解。


Interview

CodeForces - 1807E

题目描述

This is an interactive problem. If you are unsure how interactive problems work, then it is recommended to read the guide for participants.

Before the last stage of the exam, the director conducted an interview. He gave Gon n n n piles of stones, the i i i -th pile having a i a_i ai stones.

Each stone is identical and weighs 1 1 1 grams, except for one special stone that is part of an unknown pile and weighs 2 2 2 grams.


A picture of the first test case. Pile 2 2 2 has the special stone. The piles have weights of 1 , 3 , 3 , 4 , 5 1,3,3,4,5 1,3,3,4,5, respectively.Gon can only ask the director questions of one kind: he can choose k k k piles, and the director will tell him the total weight of the piles chosen. More formally, Gon can choose an integer k k k ( 1 ≤ k ≤ n 1 \leq k \leq n 1kn ) and k k k unique piles p 1 , p 2 , … , p k p_1, p_2, \dots, p_k p1,p2,,pk ( 1 ≤ p i ≤ n 1 \leq p_i \leq n 1pin ), and the director will return the total weight m p 1 + m p 2 + ⋯ + m p k m_{p_1} + m_{p_2} + \dots + m_{p_k} mp1+mp2++mpk , where m i m_i mi denotes the weight of pile i i i .

Gon is tasked with finding the pile that contains the special stone. However, the director is busy. Help Gon find this pile in at most 30 \mathbf{30} 30 queries.

输入格式

The input data contains several test cases. The first line contains one integer t t t ( 1 ≤ t ≤ 1000 1 \leq t \leq 1000 1t1000 ) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer n n n ( 1 ≤ n ≤ 2 ⋅ 1 0 5 1 \leq n \leq 2 \cdot 10^5 1n2105 ) — the number of piles.

The second line of each test case contains n n n integers a i a_i ai ( 1 ≤ a i ≤ 1 0 4 1 \leq a_i \leq 10^4 1ai104 ) — the number of stones in each pile.

It is guaranteed that the sum of n n n over all test cases does not exceed 2 ⋅ 1 0 5 2 \cdot 10^5 2105 .

After reading the input for each test case, proceed with the interaction as follows.

输出格式

You can perform the operation at most 30 \mathbf{30} 30 times to guess the pile.

To make a guess, print a line with the following format:

  • ?   k   p 1   p 2   p 3   . . .   p k − 1   p k \texttt{?}\ k \ p_1 \ p_2 \ p_3 \ ... \ p_{k-1}\ p_k ? k p1 p2 p3 ... pk1 pk ( 1 ≤ k ≤ n 1 \leq k \leq n 1kn ; 1 ≤ p i ≤ n 1 \leq p_i \leq n 1pin ; all p i p_i pi are distinct) — the indices of the piles.

After each operation, you should read a line containing a single integer x x x — the sum of weights of the chosen piles. (Formally, x = m p 1 + m p 2 + ⋯ + m p k x = m_{p_1} + m_{p_2} + \dots + m_{p_k} x=mp1+mp2++mpk .)When you know the index of the pile with the special stone, print one line in the following format: !   m \texttt{!}\ m ! m ( 1 ≤ m ≤ n 1 \leq m \leq n 1mn ).

After that, move on to the next test case, or terminate the program if there are no more test cases remaining.

If your program performs more than 30 30 30 operations for one test case or makes an invalid query, you may receive a Wrong Answer verdict.

After you print a query or the answer, please remember to output the end of the line and flush the output. Otherwise, you may get Idleness limit exceeded or some other verdict. To do this, use the following:

  • fflush(stdout) or cout.flush() in C++;
  • System.out.flush() in Java;
  • flush(output) in Pascal;
  • stdout.flush() in Python;
  • see the documentation for other languages.

It is additionally recommended to read the interactive problems guide for participants.

Hacks

To make a hack, use the following format.

The first line should contain a single integer t t t ( 1 ≤ t ≤ 1000 1 \leq t \leq 1000 1t1000 ) — the number of test cases.

The first line of each test case should contain two integers n , m n, m n,m ( ≤ n ≤ 2 ⋅ 1 0 5 \leq n \leq 2 \cdot 10^5 n2105 ) – the number of piles and the pile with the special stone.

The second line of each test case should contain n n n integers a i a_i ai ( 1 ≤ a i ≤ 1 0 4 1 \leq a_i \leq 10^4 1ai104 ) — the number of stones in each pile.

Note that the interactor is not adaptive, meaning that the answer is known before the participant asks the queries and doesn’t depend on the queries asked by the participant.


Bouncy Ball

CodeForces - 1807F

题目描述

在一个 n × m n\times m n×m 的房间内有一个球,初始位置为 ( i 1 , j 1 ) (i_1,j_1) (i1,j1),目标位置为 ( i 2 , j 2 ) (i_2,j_2) (i2,j2),初始方向为字符串 d d d

  • d = UL d=\texttt{UL} d=UL,向左上移动
  • d = DR d=\texttt{DR} d=DR,向右下移动
  • d = DL d=\texttt{DL} d=DL,向左下移动
  • d = UR d=\texttt{UR} d=UR,向右上移动

当小球碰到墙壁后会反弹,新的方向与旧方向以垂直与墙壁的一条线为轴对称。(见图)

当小球移到角落时会原地返回。

若小球会移到目标位置,问最少会反弹几次(碰到角落为一次),若无法移到,则输出 -1


Three Days Ago

AtCoder - abc295_d

题目描述

给出一个数字串,问有多少子段满足,可以以某种方式将这个子段重排,将子段分成两个完全相同的部分。


Kth Number

AtCoder - abc295_e

题目描述

We have a sequence of length N consisting of integers between 0 and M, inclusive: A = ( A 1 , A 2 , … , A N ) . A=(A_1,A_2 ,…,A_N ). A=(A1,A2,,AN).

Snuke will perform the following operations 1 and 2 in order.

  1. For each i such that A i A_i Ai =0, independently choose a uniform random integer between 1 and M, inclusive, and replace Ai with that integer.
  2. Sort A in ascending order.

Print the expected value of A K A_K AKafter the two operations, modulo 998244353.

How to print a number modulo 998244353?
It can be proved that the sought expected value is always rational. Additionally, under the Constraints of this problem, when that value is represented as P Q \frac{P}{Q} QP using two coprime integers P and Q, it can be proved that there is a unique integer R such that R×Q≡P(mod 998244353) and 0≤R<998244353. Print this R.


substr = S

AtCoder - abc295_f

题目描述

You are given a string S consisting of digits and positive integers L and R for each of T test cases. Solve the following problem.

For a positive integer x, let us define f(x) as the number of contiguous substrings of the decimal representation of x (without leading zeros) that equal S.

For instance, if S= 22, we have f(122)=1, f(123)=0, f(226)=1, and f(222)=2.
Find ∑ k = L R f ( k ) \sum\limits_{k=L}^R f(k) k=LRf(k)


Minimum Reachable City

AtCoder - abc295_g

题目描述

给定一张点数为 N N N 的有向图,初始 p i ( 1 ≤ p i ≤ i , 1 ≤ i < N ) p_i(1\leq p_i \leq i,1 \leq i < N) pi(1pii,1i<N) 连向 i + 1 i+1 i+1

Q Q Q 次操作,有两种:

  • 1 u v : u u u v v v 连一条有向边,保证最开始时 v v v 能到达 u u u u ≠ v u \ne v u=v
  • 2 x :询问 x x x 能到达的点中编号最小的点。

M<=ab

AtCoder - abc296_d

题目描述

You are given positive integers N and M.
Find the smallest positive integer X that satisfies both of the conditions below, or print −1 if there is no such integer.

  • X can be represented as the product of two integers a and b between 1 and N, inclusive. Here, a and b may be the same.
  • X is at least M.

第六周

图的遍历

洛谷 - P3916

杂务

洛谷 - P1113

Candies

CodeForces - 1810B

Make It Permutation

CodeForces - 1810C

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值