CF1476A.K-divisible Sum
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given two integers n and k.
You should create an array of n positive integers a1,a2,…,an such that the sum (a1+a2+⋯+an) is divisible by k and maximum element in a is minimum possible.
What is the minimum possible maximum element in a?
给你两个整数 n 和 k。
你需要构造一个包含 n 个正整数的数组 a1,a2,…,an,使得其和 (a1+a2+⋯+an) 能被 k 整除,且数组 a 中的最大元素尽可能小。
数组 a 中可能的最小最大值是多少?
输入格式
The first line contains a single integer t (1≤t≤1000) — the number of test cases.
The first and only line of each test case contains two integers n and k (1≤n≤109; 1≤k≤109).
第一行包含一个整数 t(1≤t≤1000)—— 测试用例的数量。
每个测试用例仅有一行,包含两个整数 n 和 k(1≤n≤109;1≤k≤109)。
输出格式
For each test case, print one integer — the minimum possible maximum element in array a such that the sum (a1+⋯+an) is divisible by k.
对于每个测试用例,输出一个整数——使得数组 a 的元素和 (a1+⋯+an) 能被 k 整除时,数组 a 中可能的最小最大值。
输入输出样例
输入#1
4 1 5 4 3 8 8 8 17
输出#1
5 2 1 3
说明/提示
In the first test case n=1, so the array consists of one element a1 and if we make a1=5 it will be divisible by k=5 and the minimum possible.
In the second test case, we can create array a=[1,2,1,2]. The sum is divisible by k=3 and the maximum is equal to 2.
In the third test case, we can create array a=[1,1,1,1,1,1,1,1]. The sum is divisible by k=8 and the maximum is equal to 1.
在第一个测试用例中,n=1,因此数组仅包含一个元素 a1;若令 a1=5,则其可被 k=5 整除,且为可能的最小值。
在第二个测试用例中,我们可以构造数组 a=[1,2,1,2]。其和可被 k=3 整除,且最大值等于 2。
在第三个测试用例中,我们可以构造数组 a=[1,1,1,1,1,1,1,1]。其和可被 k=8 整除,且最大值等于 1。
输入解题思路,AI测评打分。不知道怎么写?