f447: 12918 - Lucky Thief
Tags : CPE UVA math
Accepted rate : 37人/37人 ( 100% ) [非即時]
評分方式:
Tolerant

最近更新 : 2020-11-23 23:27

Content

小偷有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.

Input

第一行有個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.

Output

輸出至少需要失敗幾次

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.

Sample Input #1
3
4 6
1 2
500 900
Sample Output #1
14
1
324750
測資資訊:
記憶體限制: 512 MB
公開 測資點#0 (20%): 1.0s , <10M
公開 測資點#1 (20%): 1.0s , <10M
公開 測資點#2 (20%): 1.0s , <10M
公開 測資點#3 (20%): 1.0s , <10M
公開 測資點#4 (20%): 1.0s , <10M
Hint :

2020 5月CPE 第四題

Tags:
CPE UVA math
出處:
UVA12918 [管理者:
DE45A (一葉之秋)
]


ID User Problem Subject Hit Post Date
沒有發現任何「解題報告」