F - Shortest Path


  • محدودیت زمان: ۳ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

Amin and Niloufar need to travel from point (0,0)(0, 0) to (3n,3n)(3n, 3n). In normal terrain, they can travel 11 km per day. Their path is interrupted by a wide swamp that runs parallel to the xx-axis. The swamp is nn kilometers wide, with boundaries at y=ny = n and y=2ny = 2n. The map of the area is shown in the diagram below:

River

The travel speed of Amin and Niloufar through the swamp is 1k\frac{1}{k} kilometers per day. Find the shortest possible time to travel from point (0,0)(0, 0) to (3n,3n)(3n, 3n) and print the result in days.

If the shortest travel time is dd days hh hours mm minutes, and so on, print only the value dd.

ورودی🔗

The first line of input contains a positive integer tt, representing the number of test cases.

1t1051 \leq t \leq 10^5

For each test case, the only line contains two integers nn and kk.

1n,k1071 \leq n, k \leq 10^7

خروجی🔗

For each test case, print a single integer representing the minimum number of days required to reach the destination.

مثال‌ها🔗

ورودی نمونه ۱🔗

2
1 1
100 2
Plain text

خروجی نمونه ۱🔗

4
543
Plain text
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.