CF939B.Hamster Farm

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Dima has a hamsters farm. Soon N hamsters will grow up on it and Dima will sell them in a city nearby.

Hamsters should be transported in boxes. If some box is not completely full, the hamsters in it are bored, that's why each box should be completely full with hamsters.

Dima can buy boxes at a factory. The factory produces boxes of K kinds, boxes of the i-th kind can contain in themselves a__i hamsters. Dima can buy any amount of boxes, but he should buy boxes of only one kind to get a wholesale discount.

Of course, Dima would buy boxes in such a way that each box can be completely filled with hamsters and transported to the city. If there is no place for some hamsters, Dima will leave them on the farm.

Find out how many boxes and of which type should Dima buy to transport maximum number of hamsters.

迪马有一家仓鼠养殖场。很快,将有 NN 只仓鼠在该养殖场长大,迪马会把它们卖到附近的城市。

仓鼠需要用箱子运输。如果某个箱子没有装满,箱内的仓鼠就会感到无聊,因此每个箱子都必须被仓鼠完全装满。

迪马可以在一家工厂购买箱子。该工厂生产 KK 种箱子,第 ii 种箱子的容量为 aia_i 只仓鼠。迪马可以购买任意数量的箱子,但为了享受批发折扣,他只能购买同一种类的箱子。

显然,迪马会以这样的方式购买箱子:使得每个箱子都能被仓鼠完全装满并运往城市。若没有足够的空间容纳全部仓鼠,迪马会将多余的仓鼠留在养殖场。

请找出迪马应购买多少个箱子、以及购买哪一种箱子,才能运输最多数量的仓鼠。

输入格式

The first line contains two integers N and K (0 ≤ N ≤ 1018, 1 ≤ K ≤ 105) — the number of hamsters that will grow up on Dima's farm and the number of types of boxes that the factory produces.

The second line contains K integers _a_1, _a_2, ..., a__K (1 ≤ a__i ≤ 1018 for all i) — the capacities of boxes.

第一行包含两个整数 NN 和 KK(0 ≤ N ≤ 10180 \leq N \leq 10^{18},1 ≤ K ≤ 1051 \leq K \leq 10^5)—— 分别表示将在迪马农场长大的仓鼠数量,以及工厂生产的盒子种类数。

第二行包含 KK 个整数 a1,a2,…,aKa_1, a_2, \dots, a_K(对所有 ii,满足 1 ≤ ai ≤ 10181 \leq a_i \leq 10^{18})—— 表示各类盒子的容量。

输出格式

Output two integers: the type of boxes that Dima should buy and the number of boxes of that type Dima should buy. Types of boxes are numbered from 1 to K in the order they are given in input.

If there are many correct answers, output any of them.

输出两个整数:Dima 应该购买的盒子类型编号,以及该类型盒子的数量。盒子类型按输入中给出的顺序编号为 11 到 KK。

如果存在多个正确答案,输出其中任意一个即可。

输入输出样例

  • 输入#1

    19 3
    5 4 10

    输出#1

    2 4
  • 输入#2

    28 3
    5 6 30

    输出#2

    1 5

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

首页