CF1476A.K-divisible Sum

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given two integers nn and kk .

You should create an array of nn positive integers a1,a2,,ana_1, a_2, \dots, a_n such that the sum (a1+a2++an)(a_1 + a_2 + \dots + a_n) is divisible by kk and maximum element in aa is minimum possible.

What is the minimum possible maximum element in aa ?

输入格式

The first line contains a single integer tt ( 1t10001 \le t \le 1000 ) — the number of test cases.

The first and only line of each test case contains two integers nn and kk ( 1n1091 \le n \le 10^9 ; 1k1091 \le k \le 10^9 ).

输出格式

For each test case, print one integer — the minimum possible maximum element in array aa such that the sum (a1++an)(a_1 + \dots + a_n) is divisible by kk .

输入输出样例

  • 输入#1

    4
    1 5
    4 3
    8 8
    8 17

    输出#1

    5
    2
    1
    3

说明/提示

In the first test case n=1n = 1 , so the array consists of one element a1a_1 and if we make a1=5a_1 = 5 it will be divisible by k=5k = 5 and the minimum possible.

In the second test case, we can create array a=[1,2,1,2]a = [1, 2, 1, 2] . The sum is divisible by k=3k = 3 and the maximum is equal to 22 .

In the third test case, we can create array a=[1,1,1,1,1,1,1,1]a = [1, 1, 1, 1, 1, 1, 1, 1] . The sum is divisible by k=8k = 8 and the maximum is equal to 11 .

首页