#P1944A. Destroying Bridges

Destroying Bridges

Destroying Bridges

题面翻译

nn 个岛屿,编号为 1,2,,n1, 2, \ldots, n 。最初,每对岛屿都由一座桥连接。因此,一共有 n(n1)2\frac{n (n - 1)}{2} 座桥。

Everule 住在 11 岛上,喜欢利用桥梁访问其他岛屿。Dominater 有能力摧毁最多 kk 座桥梁,以尽量减少 Everule 可以使用(可能是多座)桥梁到达的岛屿数量。

如果 Dominater 以最佳方式摧毁桥梁,求 Everule 可以访问的岛屿(包括岛屿 11 )的最少数量。

题目描述

There are n n islands, numbered 1,2,,n 1, 2, \ldots, n . Initially, every pair of islands is connected by a bridge. Hence, there are a total of n(n1)2 \frac{n (n - 1)}{2} bridges.

Everule lives on island 1 1 and enjoys visiting the other islands using bridges. Dominater has the power to destroy at most k k bridges to minimize the number of islands that Everule can reach using (possibly multiple) bridges.

Find the minimum number of islands (including island 1 1 ) that Everule can visit if Dominater destroys bridges optimally.

输入格式

Each test contains multiple test cases. The first line contains a single integer t t ( 1t103 1 \leq t \leq 10^3 ) — the number of test cases. The description of the test cases follows.

The first and only line of each test case contains two integers n n and k k ( 1n100 1 \le n \le 100 , 0kn(n1)2 0 \le k \le \frac{n \cdot (n - 1)}{2} ).

输出格式

For each test case, output the minimum number of islands that Everule can visit if Dominater destroys bridges optimally.

样例 #1

样例输入 #1

6
2 0
2 1
4 1
5 10
5 3
4 4

样例输出 #1

2
1
4
1
5
1

提示

In the first test case, since no bridges can be destroyed, all the islands will be reachable.

In the second test case, you can destroy the bridge between islands 1 1 and 2 2 . Everule will not be able to visit island 2 2 but can still visit island 1 1 . Therefore, the total number of islands that Everule can visit is 1 1 .

In the third test case, Everule always has a way of reaching all islands despite what Dominater does. For example, if Dominater destroyed the bridge between islands 1 1 and 2 2 , Everule can still visit island 2 2 by traveling by 132 1 \to 3 \to 2 as the bridges between 1 1 and 3 3 , and between 3 3 and 2 2 are not destroyed.

In the fourth test case, you can destroy all bridges since k=n(n1)2 k = \frac{n \cdot (n - 1)}{2} . Everule will be only able to visit 1 1 island (island 1 1 ).