f447. 12918 - Lucky Thief
標籤 : CPE UVA math
通過比率 : 150人/155人 ( 97% ) [非即時]
評分方式:
Tolerant

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

內容

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

範例輸入 #1
3
4 6
1 2
500 900
範例輸出 #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
提示 :

2020 5月CPE 第四題

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

本題狀況 本題討論 排行

編號 身分 題目 主題 人氣 發表日期
33876 wubaie (小億) f447
232 2023-02-10 09:12