4080 - Empty Water Tank

Created by Yonny Mondelo Hernández
Added by ymondelo20 (2018-09-05)
Limits
Total Time: 30000 MS | Test Time: 1000 MS |Memory: 512 MB | Output: 64 MB | Size: 16 KB
Enabled languages
Available in

Description

A water tank with a capacity of C liters needs to be filled. To accomplish that, there is a system that pours a positive amount of F liters into the tank during the first minute (F is the starting water flow). Then F+1 liters pour in during the second minute, F+2 in the third minute, and so on; in minute T the system will pour exactly F+T-1 liters of water into the tank.

Determine the minimum value of F that allows for filling the water tank in at most T minutes (i.e. the tank is filled in T minutes or less).
Se necesita llenar un tanque de agua con una capacidad de C litros. Para lograr eso, hay un sistema que vierte una cantidad positiva de F litros en el tanque durante el primer minuto (F es el flujo de agua inicial). Luego, F + 1 litros se viertes durante el segundo minuto, F + 2 en el tercer minuto, y así sucesivamente; en el minuto T, el sistema vertirá exactamente F + T-1 litros de agua en el tanque.

Determine el valor mínimo de F que permite llenar el tanque de agua a lo sumo en T minutos (es decir, el tanque se llena en T minutos o menos).
A water tank with a capacity of C liters needs to be filled. To accomplish that, there is a system that pours a positive amount of F liters into the tank during the first minute (F is the starting water flow). Then F+1 liters pour in during the second minute, F+2 in the third minute, and so on; in minute T the system will pour exactly F+T-1 liters of water into the tank.

Determine the minimum value of F that allows for filling the water tank in at most T minutes (i.e. the tank is filled in T minutes or less).

Input specification

The first line will contain an integer N (1 N 103), representing the number of cases. The following N lines will contain two space-separated integer numbers C (1 C 1016) and T (1 T 108), representing the capacity of the tank and number of minutes to fill it.
La primera línea contendrá un entero N (1 ≤ N ≤ 10^3), que representa el número de casos. Las siguientes N líneas contendrán dos números enteros C (1 ≤ C ≤ 10^16) y T (1 ≤ T ≤ 10^8) separados por un espacio, que representan la capacidad del tanque y el número de minutos para llenarlo.

The first line will contain an integer N (1 N 103), representing the number of cases. The following N lines will contain two space-separated integer numbers C (1 C 1016) and T (1 T 108), representing the capacity of the tank and number of minutes to fill it.

Output specification

For each case, you must output a line with an integer: the minimum starting water flow F that allows the water tank to fill in T minutes or less.
Para cada caso, debe imprimir una línea con un número entero: el flujo de agua inicial mínimo F que permite que el tanque de agua se llene en T minutos o menos.

The first line will contain an integer N (1 N 103), representing the number of cases. The following N lines will contain two space-separated integer numbers C (1 C 1016) and T (1 T 108), representing the capacity of the tank and number of minutes to fill it.

Sample input

5
15 4
55 10
100 2
25 20
999 1

Sample output

3
1
50
1
999

Hint(s)