Logo
(追記) (追記ここまで)

18688번 - Military Service 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB100564758.025%

문제

You have just started your military service with the border guards. Since you are a Computer Science graduate, they asked you to implement a schedule for the soldiers. Initially no soldier is on duty and you need the schedule to satisfy 2 requirements:

  • There are N soldiers, each soldier can be on duty for at most K continuous months and then he must take one month of vacation.
  • The schedule needs to make sure that the guaranteed minimum number of soldiers on duty at any given time is maximized.

Given N and K, the system will calculate the maximum guaranteed number of soldiers to be on duty at any given time.

입력

Your program will be tested on one or more test cases. The first line of the input will be a single integer T, the number of test cases (1 ≤ T ≤ 100).

Each test case consists of a line containing 2 space separated integers:

  • N: The number of soldiers (0 ≤ N ≤ 10, 000, 000)
  • K: The number of continuous months a soldier can be on duty before they have to take a month of vacation (0 ≤ K ≤ 10, 000, 000).

출력

For each test case, print a single line containing the maximum guaranteed number of soldiers on duty at any given time.

제한

예제 입력 1

3
4 1
9 3
21 3

예제 출력 1

2
6
15

힌트

출처

ICPC > Regionals > Africa and Arab > Arab Collegiate Programming Contest > 2016 Arab Collegiate Programming Contest H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /