CF1476A.K-divisible Sum

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

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?

给你两个整数 nn 和 kk。

你需要构造一个包含 nn 个正整数的数组 a1,a2,…,ana_1, a_2, \dots, a_n,使得其和 (a1+a2+⋯+an)(a_1 + a_2 + \dots + a_n) 能被 kk 整除,且数组 aa 中的最大元素尽可能小。

数组 aa 中可能的最小最大值是多少?

输入格式

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

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

第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000)—— 测试用例的数量。

每个测试用例仅有一行,包含两个整数 nn 和 kk(1≤n≤1091 \le n \le 10^9;1≤k≤1091 \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.

对于每个测试用例,输出一个整数——使得数组 aa 的元素和 (a1+⋯+an)(a_1 + \dots + a_n) 能被 kk 整除时,数组 aa 中可能的最小最大值。

输入输出样例

  • 输入#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.

在第一个测试用例中,n=1n = 1,因此数组仅包含一个元素 a1a_1;若令 a1=5a_1 = 5,则其可被 k=5k = 5 整除,且为可能的最小值。

在第二个测试用例中,我们可以构造数组 a=[1,2,1,2]a = [1, 2, 1, 2]。其和可被 k=3k = 3 整除,且最大值等于 22。

在第三个测试用例中,我们可以构造数组 a=[1,1,1,1,1,1,1,1]a = [1, 1, 1, 1, 1, 1, 1, 1]。其和可被 k=8k = 8 整除,且最大值等于 11。

输入解题思路,AI测评打分。不知道怎么写?

首页