题库练习 The Good Array
← 上一题 下一题 →

A16042 | The Good Array

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You are given two integers $n$ and $k$ .

An array $a_1, a_2, \ldots, a_n$ of length $n$ , consisting of zeroes and ones is good if for all integers $i$ from $1$ to $n$ both of the following conditions are satisfied:

- at least $\lceil \frac{i}{k} \rceil$ of the first $i$ elements of $a$ are equal to $1$ ,
- at least $\lceil \frac{i}{k} \rceil$ of the last $i$ elements of $a$ are equal to $1$ .

Here, $\lceil \frac{i}{k} \rceil$ denotes the result of division of $i$ by $k$ , rounded up. For example, $\lceil \frac{6}{3} \rceil = 2$ , $\lceil \frac{11}{5} \rceil = \lceil 2.2 \rceil = 3$ and $\lceil \frac{7}{4} \rceil = \lceil 1.75 \rceil = 2$ .

Find the minimum possible number of ones in a good array.

输入格式

Each test contains multiple test cases. The first line contains a single integer $t$ ( $1 \le t \le 10^4$ ) — the number of test cases.

The only line of each test case contains two integers $n$ , $k$ ( $2 \le n \le 100$ , $1 \le k \le n$ ) — the length of array and parameter $k$ from the statement.

输出格式

For each test case output one integer — the minimum possible number of ones in a good array.

It can be shown that under the given constraints at least one good array always exists.

输入输出样例

输入 #1
7
3 2
5 2
9 3
7 1
10 4
9 5
8 8
输出 #1
2
3
4
7
4
3
2
C++ 编辑器
输入
输出