B. Hamster Farm

time limit per test2 seconds

memory limit per test256 megabytes

Problem Description

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 ≤ 10e18, 1 ≤ K ≤ 10e5) — 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 ≤ 10e18 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

19 3

5 4 10

output

2 4

input

28 3

5 6 30

output

1 5


解题心得:

  1. 题意是一个农夫有n只仓鼠,k中笼子,每种笼子可以装Ki只仓鼠,只有笼子装满才能将仓鼠带走,选择一种笼子,要使带走的仓鼠最多,问最少要多少个笼子。
  2. 暴力,每次mod一下找最小值。
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+100;
ll k[maxn],sum,K; int main(){
scanf("%lld%lld",&sum,&K);
ll ans_pos = -1,Min = 1e18;
for(int i=1;i<=K;i++){
scanf("%lld",&k[i]);
ll temp = sum%k[i];
if(temp < Min){
Min = temp;
ans_pos = i;
}
}
printf("%lld %lld",ans_pos,sum/k[ans_pos]);
return 0;
}

Codeforces Round #464 (Div. 2) B. Hamster Farm的更多相关文章

  1. Codeforces Round #464 (Div. 2) B. Hamster Farm[盒子装仓鼠/余数]

    B. Hamster Farm time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  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. PHP面试题及答案(五)

    1. 禁用COOKIE 后 SEESION 还能用吗? 答案: 不能. 2. 抓取远程图片到本地,你会用什么函数? 答案: fsockopen(). 3.求两个日期的差数,例如2007-2-5 ~ 2 ...

  2. ubuntu下apk的反编译

    今天调试一个程序的时候,因为需要上传数据到服务器,但是程序太过久远了,服务器上传的地址就忘记了,但是源码又不在我这里,因为要的急所以就被逼无奈的情况下想到了反编译,我用的是Linux Mint 14. ...

  3. Day5 CSS基本样式和C3选择器

    Day5 CSS基本样式和C3选择器 一.背景属性 1.背景颜色            background-color:transparent(默认值,透明); 颜色的取值:            ...

  4. redis---安全设置

    redis的安全性是通过设置口令来实现的. 首先打开redis的配置文件,我的是在/etc/redis/redis.conf,个人的路径可能会有不同,可以自行查找. 打开redis.conf文件以后, ...

  5. ubuntu 16.04安装nVidia显卡驱动和cuda/cudnn踩坑过程

    安装深度学习框架需要使用cuda/cudnn(GPU)来加速计算,而安装cuda/cudnn,首先需要安装nvidia的显卡驱动. 我在安装的整个过程中碰到了驱动冲突,循环登录两个问题,以至于最后不得 ...

  6. 菜鸟 学注册机编写之 “MD5”

    测试环境  系统: xp sp3 调试器 :od 1.10 sc_office_2003_pro 高手不要见笑,仅供小菜玩乐,有不对或不足的地方还请多多指教,不胜感激! 一:定位关键CALL 1. 因 ...

  7. python 之 BeautifulSoup 常用提取

    一.bs4信息提取后返回的数据类型 soup.find('tbody') ---> 返回结构是一个bs4.element.Tag soup.find('tbody').children ---& ...

  8. 美国移民局的I797表原件和I129表是什么呢

    I-129表,Petition for a Non-immigrant Worker,即非移民工作许可申请表I797 表 ,Original L1-1A approval notice L1签证批准通 ...

  9. LeetCode Longest Substring Without Repeating Characters 最长不重复子串

    题意:给一字符串,求一个子串的长度,该子串满足所有字符都不重复.字符可能包含标点之类的,不仅仅是字母.按ASCII码算,就有2^8=128个. 思路:从左到右扫每个字符,判断该字符距离上一次出现的距离 ...

  10. codeblocks winsock配置

    在codeblocks进行Socket编程遇到如下情况: undefined reference to WSAStartup@8 解决方法: 右击工程,选择 build options,选择 Link ...