小偷有n把鑰使與m棟的房子,小偷想要找出鑰使與房間的配對,每個鑰使只能跟一個房間配對。
詢問在有邏輯分析的情況下,小偷至少需要失敗幾次才能成功知道每個 key 要配每個房間。
A very lucky thief found n keys on a street with m houses. He knows that each key opens exactly one door so he wants to know which door is, but he also wants to do the less number of tries in order to avoid the security systems.
第一行有個T代表測資數(T ≤ 100000)
接下來T行有n,m(1 ≤ n ≤ m ≤ 100000)
The first line contains a single integer, T (T ≤ 100000) indicating the number of test cases. The following T lines contain two integers n and m, 1 ≤ n ≤ m ≤ 100000.
輸出至少需要失敗幾次
Print the minimum number of tries that the thief must perform in order to know what key opens each door with an end of line.
3 4 6 1 2 500 900
14 1 324750
2020 5月CPE 第四題