2026年10月7日

2 道题返回最新一期
G
Uniform Change
GYM106744G
1000GYM1 second256 megabytes
Codeforces

G. 均匀变化AI (CI翻译)(GLM 5.3 Flash)

题目描述

A cashier has an infinite number of banknotes with denominations $1, 2, \ldots, K$.

一位收银员有无限多张面额为 $1, 2, \ldots, K$ 的纸币。AI (CI翻译)(GLM 5.3 Flash)

The cashier prefers the stacks of banknotes to end uniformly:

收银员希望成叠的钞票末端整齐一致:AI (CI翻译)(GLM 5.3 Flash)

Suppose the cashier gives change as $C_1$ banknotes of denomination $1$, $C_2$ banknotes of denomination $2$, ..., $C_K$ banknotes of denomination $K$.

假设收银员找零时给出 $C_1$ 张面额为 $1$ 的纸币、$C_2$ 张面额为 $2$ 的纸币、……、$C_K$ 张面额为 $K$ 的纸币。AI (CI翻译)(GLM 5.3 Flash)

The cashier wants the maximum value among $C_1, C_2, \ldots, C_K$ to be as small as possible.

收银员希望 $C_1, C_2, \ldots, C_K$ 中的最大值尽可能小。AI (CI翻译)(GLM 5.3 Flash)

Help the cashier — find any way to give $N$ units of change uniformly.

帮助收银员——找出任意一种均匀给出 $N$ 单位找零的方法。AI (CI翻译)(GLM 5.3 Flash)

输入格式

The only line contains two integers $N$ and $K$ separated by a space ($1 \le N \le 10^{18}$; $1 \le K \le 2 \cdot 10^5$) — the amount of change and the number of different available denominations.

唯一一行包含两个用空格分隔的整数 $N$ 和 $K$($1 \le N \le 10^{18}$;$1 \le K \le 2 \cdot 10^5$)——零钱金额和不同可用面额的数量。AI (CI翻译)(GLM 5.3 Flash)

输出格式

Print $K$ integers $C_1, C_2, \ldots, C_K$ ($0 \le C_i \le N$) separated by spaces — the number of banknotes of denomination $i$ in a uniform change of $N$.

输出用空格分隔的 $K$ 个整数 $C_1, C_2, \ldots, C_K$($0 \le C_i \le N$)——在 $N$ 的一种均匀兑换中,面额为 $i$ 的纸币数量。AI (CI翻译)(GLM 5.3 Flash)

The answer must satisfy the following conditions:

答案必须满足以下条件:AI (CI翻译)(GLM 5.3 Flash)

$\sum_{i=1}^{K} C_i \cdot i = N$ — exactly $N$ units of change are given;

$\sum_{i=1}^{K} C_i \cdot i = N$ —— 恰好给出了 $N$ 个单位的零钱;AI (CI翻译)(GLM 5.3 Flash)

$\max(C_1, C_2, \ldots, C_K)$ is minimal among all ways to give change of size $N$ using denominations from $1$ to $K$.

在所有使用从 $1$ 到 $K$ 的面额为金额 $N$ 找零的方式中,$\max(C_1, C_2, \ldots, C_K)$ 是最小的。AI (CI翻译)(GLM 5.3 Flash)

If there are multiple answers satisfying the conditions, print any of them.

如果有多个满足条件的答案,输出其中任意一个。AI (CI翻译)(GLM 5.3 Flash)

备注

In the first example, the cashier gave:

在第一个样例中,收银员给了:AI (CI翻译)(GLM 5.3 Flash)

$C_1 = 2$ banknotes of denomination $1$;

$C_1 = 2$ 张面额为 $1$ 的纸币;AI (CI翻译)(GLM 5.3 Flash)

$C_2 = 1$ banknote of denomination $2$;

$C_2 = 1$ 面额为 $2$ 的纸币;AI (CI翻译)(GLM 5.3 Flash)

$C_3 = 2$ banknotes of denomination $3$.

$C_3 = 2$ 张面额为 $3$ 的纸币。AI (CI翻译)(GLM 5.3 Flash)

In total, the cashier gave $C_1 \cdot 1 + C_2 \cdot 2 + C_3 \cdot 3 = 10$ units.

评分器总共给出了 $C_1 \cdot 1 + C_2 \cdot 2 + C_3 \cdot 3 = 10$ 个单位。AI (CI翻译)(GLM 5.3 Flash)

In the second example, the cashier gave:

在第二个样例中,收银员给了:AI (CI翻译)(GLM 5.3 Flash)

$1$ banknote of denomination $1$;

$1$ 面额为 $1$ 的纸币;AI (CI翻译)(GLM 5.3 Flash)

$3$ banknotes each of denominations $2, 3, 4, 5, 6$;

$3$ 张纸币,面额分别为 $2, 3, 4, 5, 6$;AI (CI翻译)(GLM 5.3 Flash)

$0$ banknotes of denomination $7$.

$0$ 张面值为 $7$ 的纸币。AI (CI翻译)(GLM 5.3 Flash)

In total, the cashier gave $1 \cdot 1 + 3 \cdot (2 + 3 + 4 + 5 + 6) + 0 \cdot 7 = 61$ units.

收银员总共给了 $1 \cdot 1 + 3 \cdot (2 + 3 + 4 + 5 + 6) + 0 \cdot 7 = 61$ 个单位。AI (CI翻译)(GLM 5.3 Flash)

Note that this is only one possible answer with $\max(C_1, \ldots, C_7) = 3$. It can be shown that there is no answer where $\max(C_1, \ldots, C_7)$ is less than $3$.

注意,这只是 $\max(C_1, \ldots, C_7) = 3$ 的一种可能答案。可以证明,不存在 $\max(C_1, \ldots, C_7)$ 小于 $3$ 的答案。AI (CI翻译)(GLM 5.3 Flash)

样例

样例 1

Input
10 3
Output
2 1 2

样例 2

Input
61 7
Output
1 3 3 3 3 3 0

A
Points
GYM103627A
2100GYM10 s1024 mebibytes
Codeforces

A. 点AI (CI翻译)(GLM 5.3 Flash)

题目描述

There are two multisets $U$ and $V$ that contain two-dimensional points with integer coordinates.

有两个多重集 $U$ 和 $V$,它们包含坐标为整数的二维点。AI (CI翻译)(GLM 5.3 Flash)

We will define the following function $D(U, V)$ for a pair of multisets:

对于一对多重集,我们定义以下函数 $D(U, V)$:AI (CI翻译)(GLM 5.3 Flash)

$D(U, V) = -1$ if either set is empty.

如果任一集合为空,则 $D(U, V) = -1$。AI (CI翻译)(GLM 5.3 Flash)

D(U,V)=min(ux,uy)∈U(vx,vy)∈Vmax(ux+vx,uy+vy)$D(U, V) = \min\limits_{\begin{smallmatrix}(u_x, u_y) \in U \\ (v_x, v_y) \in V\end{smallmatrix}}\max(u_x + v_x, u_y + v_y)$ otherwise.

D(U,V)=min(ux,uy)∈U(vx,vy)∈Vmax(ux+vx,uy+vy)$D(U, V) = \min\limits_{\begin{smallmatrix}(u_x, u_y) \in U \\ (v_x, v_y) \in V\end{smallmatrix}}\max(u_x + v_x, u_y + v_y)$ 否则。AI (CI翻译)(GLM 5.3 Flash)

In the beginning, both $U$ and $V$ are empty. Process $Q$ queries of the following form:

初始时,$U$ 和 $V$ 均为空。处理 $Q$ 个如下形式的查询:AI (CI翻译)(GLM 5.3 Flash)

"1 $s$ $x$ $y$": Add a point $(x, y)$ to one of the sets. If $s = 1$, add the point to $U$. Otherwise, add the point to $V$.

"1 $s$ $x$ $y$": 向其中一个集合添加一个点 $(x, y)$。如果 $s = 1$,则将该点加入 $U$。否则,将该点加入 $V$。AI (CI翻译)(GLM 5.3 Flash)

"2 $s$ $x$ $y$": Delete a point $(x, y)$ from one of the sets. If $s = 1$, delete the point from $U$. Otherwise, delete the point from $V$.

“2 $s$ $x$ $y$”:从其中一个集合中删除点 $(x, y)$。如果 $s = 1$,则从 $U$ 中删除该点。否则,从 $V$ 中删除该点。AI (CI翻译)(GLM 5.3 Flash)

When deleting a point, if there are multiple points at the given coordinates, you should delete only one of them. It is guaranteed that the given point exists in the given multiset at the time of each deletion.

删除一个点时,如果给定坐标处有多个点,你应当只删除其中一个。保证每次删除时,给定的点都存在于给定的多重集中。AI (CI翻译)(GLM 5.3 Flash)

Your task is to process the queries. After each query, print the value $D(U, V)$.

你的任务是处理询问。每次询问后,输出 $D(U, V)$ 的值。AI (CI翻译)(GLM 5.3 Flash)

输入格式

The first line contains a single integer $Q$ ($1 \le Q \le 250\,000$).

第一行包含一个整数 $Q$ ($1 \le Q \le 250\,000$)。AI (CI翻译)(GLM 5.3 Flash)

Each of the next $Q$ lines contains a query in the form described above. Constraints for both types of queries: $s \in \{1, 2\}$, $0 \le x, y \le 250\,000$.

接下来的 $Q$ 行每行包含一个如上所述形式的询问。两类询问的约束条件均为:$s \in \{1, 2\}$,$0 \le x, y \le 250\,000$。AI (CI翻译)(GLM 5.3 Flash)

输出格式

Output $Q$ lines. Each line should contain the value $D(U, V)$ after the corresponding query.

输出 $Q$ 行。每行应包含对应查询后的 $D(U, V)$ 的值。AI (CI翻译)(GLM 5.3 Flash)

样例

样例 1

Input
6
1 1 100 100
1 2 30 130
1 1 120 170
2 1 100 100
1 2 70 100
2 1 120 170
Output
-1
230
230
300
270
-1