## A. Pens and Pencils

### 题意

$t$组数据，每组$a,b,c,d,k$

## B. Rooms and Staircases

### 题解

$ans\ge n$

## C. The Football Season

### 题意

Berland capital team比了$n$场比赛，总得分为$p$。已知胜一场得$w$分，平局$d$分，败了$0$分。

• $x \times w + y \times d=p$
• $x+y+z=n$

The first line contains four integers $n$ , $p$ , $w$ and $d$ $(1 \le n \le 10^{12}, 0 \le p \le 10^{17}, 1 \le d < w \le 10^{5})$ — the number of games, the number of points the team got, the number of points awarded for winning a match, and the number of points awarded for a draw, respectively. Note that $w > d$ , so the number of points awarded for winning is strictly greater than the number of points awarded for draw.

### 题解

$z=n-(x+y)$，显然$x+y$越小越好。根据$w>d$，那么$y$越小，$x+y$越小。$d$较小，而满足条件的$y\in[0,w)$，所以枚举$y$即可。也可以在$\pmod w$下用同余方程的方法做。

## D. Paint the Tree

### 题意

$3\le n\le 10^5$

## F. Chips

### 题意

$n$个棋子排成环状，标号为$1..n$

$n\ (3 \leq n \leq 2\cdot 10^5)$$k\ (1 \leq k \leq 10^9)$

### 题解

B W相间的区间提出来，每执行一次操作，它的两个端点就会变成$a[L-1],a[R+1]$

## G. Running in Pairs

### 题意

$\sum^n_{i=1} \max(p_i,q_i)$尽量大且不超过给定的$k$
n和k $(1\le n\le 10^6,1\le k\le n^2)$