A11599 | Hamster Farm
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The first line contains two integers $N$ and $K$ ( $0<=N<=10^{18}$ , $1<=K<=10^{5}$ ) — 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}<=10^{18}$ for all $i$ ) — the capacities of boxes.
The second line contains $K$ integers $a_{1}$ , $a_{2}$ , ..., $a_{K}$ ( $1<=a_{i}<=10^{18}$ for all $i$ ) — the capacities of boxes.
输出格式
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.
If there are many correct answers, output any of them.
输入输出样例
输入 #1
19 3 5 4 10
输出 #1
2 4
输入 #2
28 3 5 6 30
输出 #2
1 5
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted