B. Hamster Farm
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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 ai 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.

Input

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 a1, a2, ..., aK (1 ≤ ai ≤ 1018 for all i) — the capacities of boxes.

Output

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.

Examples
Input

Copy
19 3
5 4 10
Output
2 4
Input

Copy
28 3
5 6 30
Output
1 5

[题意]:

Dima有n 只仓鼠,有k 种盒子,每种盒子编号为1~k,可以装ai​ 只仓鼠,所有盒子都要装满仓鼠,剩下的仓鼠不装,Dima想让剩下的仓鼠最少,求应选盒子和盒子总数,如果有多种情况,输出任意一种。

输入格式:第一行为n和k,第二行为a1​,a2​,…,ak​ 。

输出格式:一行,两个整数,表示应选盒子种类的编号和盒子总数。

[分析]:先找到n%a[i]的最小值,再根据最小值找pos=i+1; num=n/a[i]编号、数量.

[代码]:

#include<bits/stdc++.h>

using namespace std;
const int maxn = 1e5+;
const long long inf=1e18+;
#define ll long long
int main()
{
ll n,k,a[maxn],pos,num,mi;
cin>>n>>k;
mi=inf;
for(ll i=;i<k;i++){
cin>>a[i];
mi=min(mi,n%a[i]);
} for(ll i=;i<k;i++){
if(n%a[i]==mi){
pos=i+;
num=n/a[i];
}
}
cout<<pos<<" "<<num<<endl; }

Codeforces Round #464 (Div. 2) B. Hamster Farm[盒子装仓鼠/余数]的更多相关文章

  1. Codeforces Round #464 (Div. 2) B. Hamster Farm

    B. Hamster Farm time limit per test2 seconds memory limit per test256 megabytes Problem Description ...

  2. Codeforces Round #464 (Div. 2)

    A. Love Triangle time limit per test: 1 second memory limit per test: 256 megabytes input: standard ...

  3. Codeforces Round #464 (Div. 2) E. Maximize!

    题目链接:http://codeforces.com/contest/939/problem/E E. Maximize! time limit per test3 seconds memory li ...

  4. Codeforces Round #464 (Div. 2) D. Love Rescue

    D. Love Rescue time limit per test2 seconds memory limit per test256 megabytes Problem Description V ...

  5. Codeforces Round #464 (Div. 2) C. Convenient For Everybody

    C. Convenient For Everybody time limit per test2 seconds memory limit per test256 megabytes Problem ...

  6. Codeforces Round #464 (Div. 2) A Determined Cleanup

    A. Love Triangle time limit per test1 second memory limit per test256 megabytes Problem Description ...

  7. Codeforces Round #464 (Div. 2) A. Love Triangle[判断是否存在三角恋]

    A. Love Triangle time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  8. Codeforces Round #464 (Div. 2) D题【最小生成树】

    Valya and Tolya are an ideal pair, but they quarrel sometimes. Recently, Valya took offense at her b ...

  9. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

随机推荐

  1. javaScripct入门教程

    1.JavaScript环境安装 JavaScript是一个轻量级的编程语言,安装自然很简单. a.打开你的电脑,找到一个Web浏览器,再找一个文本编辑器(比如记事本) b.没有了... 2.Java ...

  2. 商品评分效果JavaScript

    <script> window.onload=function(){ //----------选中的星星会多出一个属性:isClick="true" 藉此来获取评分-- ...

  3. Eclipse配置Maven工具

    1.Maven安装,下载Maven二进行制文件: http://maven.apache.org/download.cgi 下载后解压,然后设置maven的bin目录到系统环境变量Path中,在cmd ...

  4. Creating Hyperv Agent Installer

    Creating Hyperv Agent Installer   Skip to end of metadata   Created by Anshul Gangwar, last modified ...

  5. 12个scp传输文件的命令栗子

    12个scp传输文件的命令栗子 一直在用scp进行简单的远程复制文件的功能,今天无意间看到一篇介绍scp的文章,便想着学习学习并将其翻译了过来.原文戳这里.翻译不对的地方,敬请指正. 另外我最近搭建了 ...

  6. Boost入门

    [转载网友转载的 不过不知道原作者地址] Boost入门向导 简介:boost是一套开源的.高度可移植的C++模板库.它由C++标准委员发起,且里面很多组件有望成为下一代的C++标准库,其地位将会与S ...

  7. BugKu-妹子的陌陌

    打开后看这张图片,先放winhex里面,文件头FFD8,是jpg图片.看文件尾并不是FFD9,所以binwalk分析一下. 发现有一个rar文件,然后用foremost分离.发现里面有个加密的rar文 ...

  8. Android SDK 目录详解(转)

    Android SDK目录结构和工具介绍是本文要介绍的内容,主要是来了解并学习Android SDK的内容,具体关于Android SDK内容的详解来看本文. Android SDK目录下有很多文件夹 ...

  9. mongo命令

    安装mongo http://docs.mongodb.org/master/tutorial/install-mongodb-on-redhat-centos-or-fedora-linux/ 启动 ...

  10. PageObject模式简介

    一.原理 将页面元素定位和对元素的操作行为封装成一个page类,实现对页面对象和测试用例的分离. 一条测试用例可能需要多个步骤操作元素,将每个步骤单独的封装成一个方法,在执行测试用例的时候调用封装好的 ...