CF1417A.Copy-paste

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

— Hey folks, how do you like this problem?

— That'll do it.

BThero is a powerful magician. He has got nn piles of candies, the ii-th pile initially contains aia_i candies. BThero can cast a copy-paste spell as follows:

  1. He chooses two piles (i,j)(i, j) such that 1≤i,j≤n1 \le i, j \le n and i≠ji \ne j.
  2. All candies from pile ii are copied into pile jj. Formally, the operation aj:=aj+aia_j := a_j + a_i is performed.

BThero can cast this spell any number of times he wants to — but unfortunately, if some pile contains strictly more than kk candies, he loses his magic power. What is the maximum number of times BThero can cast the spell without losing his power?

— 嘿,各位,你们觉得这道题怎么样?

— 这样就可以了。

BThero 是一位强大的魔法师。他拥有 nn 堆糖果,其中第 ii 堆最初包含 aia_i 颗糖果。BThero 可以施放一种“复制-粘贴”法术,具体操作如下:

  1. 他选择两堆糖果 (i,j)(i, j),满足 1≤i,j≤n1 \le i, j \le n 且 i≠ji \ne j;
  2. 将第 ii 堆的所有糖果复制到第 jj 堆中。形式化地,执行操作 aj:=aj+aia_j := a_j + a_i。

BThero 可以任意多次施放该法术——但不幸的是,一旦某堆糖果的数量严格超过 kk 颗,他便会失去魔法力量。那么,在不失去魔法力量的前提下,BThero 最多能施放多少次该法术?

输入格式

The first line contains one integer TT (1≤T≤5001 \le T \le 500) — the number of test cases.

Each test case consists of two lines:

  • the first line contains two integers nn and kk (2≤n≤10002 \le n \le 1000, 2≤k≤1042 \le k \le 10^4);
  • the second line contains nn integers a1a_1, a2a_2, ..., ana_n (1≤ai≤k1 \le a_i \le k).

It is guaranteed that the sum of nn over all test cases does not exceed 10001000, and the sum of kk over all test cases does not exceed 10410^4.

第一行包含一个整数 TT(1≤T≤5001 \le T \le 500)—— 测试用例的数量。

每个测试用例由两行组成:

  • 第一行包含两个整数 nn 和 kk(2≤n≤10002 \le n \le 1000,2≤k≤1042 \le k \le 10^4);
  • 第二行包含 nn 个整数 a1a_1, a2a_2, ..., ana_n(1≤ai≤k1 \le a_i \le k)。

保证所有测试用例的 nn 之和不超过 10001000,且所有测试用例的 kk 之和不超过 10410^4。

输出格式

For each test case, print one integer — the maximum number of times BThero can cast the spell without losing his magic power.

对于每个测试用例,输出一个整数——BThero 在不耗尽魔法值的情况下最多能施放法术的次数。

输入输出样例

  • 输入#1

    3
    2 2
    1 1
    3 5
    1 2 3
    3 7
    3 2 2

    输出#1

    1
    5
    4

说明/提示

In the first test case we get either a=[1,2]a = [1, 2] or a=[2,1]a = [2, 1] after casting the spell for the first time, and it is impossible to cast it again.

在第一个测试用例中,第一次施法后,我们得到的数组 aa 要么是 [1,2][1, 2],要么是 [2,1][2, 1],且无法再次施法。

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

首页