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. Spring.Net初认识——竹子整理

    留个脚印,过两天总结. 看到知乎上有人对于DI|IOC 的解释,满不错,收藏下先 作者:OneNoodle链接:http://www.zhihu.com/question/23277575/answe ...

  2. Diycode开源项目 SettingActivity分析

    1.整体效果预览及布局分析 1.1.设置界面预览 1.2.主体对应关系 注意这里的线条用ImageView来实现 有一个TextView是检查更新,默认隐藏,具体出现时间还得之后确认. 最后一个Lin ...

  3. VBA连接到SQL2008需要加上端口号

    VBA连接到SQL2008需要加上端口号1433,比如 conn = "server=XXXX.XXXX.XXXX.XXXX,1433;provider=SQLOLEDB.1;databas ...

  4. [原]sencha touch之panel和tabpanel

    最近在弄senchatouch的项目,所以边学习边开发,边记录,直接记录下test code如下: Panel: Ext.application({ name:'itKingApp', launch: ...

  5. Python框架之Django学习笔记(五)

    第一个Django网页小结 进来的请求转入/hello/. Django通过在ROOT_URLCONF配置来决定根URLconf. Django在URLconf中的所有URL模式中,查找第一个匹配/h ...

  6. IOS开发学习笔记023-UIToolBar的使用

    这里使用代码实现 大概过程: 1.创建工具条 2.创建插入条 3.添加头像.标签.删除按钮 4.点击头像获取标签信息 做一个简单的联系人列表,可以添加删除联系人,现在还没有添加头像和文字,接下来慢慢添 ...

  7. 用nc+简单bat/vbs脚本+winrar制作迷你远控后门

    前言 某大佬某天和我聊起了nc,并且提到了nc正反向shell这个概念. 我对nc之前的了解程度仅局限于:可以侦听TCP/UDP端口,发起对应的连接. 真正的远控还没实践过,所以决定写个小后门试一试. ...

  8. Linux 必要软件的安装与配置

    主要是记录一下,免得下次重装系统后又到处搜索.. 一.必要软件的安装 JDK 下载 tar.gz:http://www.oracle.com/technetwork/java/javase/downl ...

  9. Selenium - WebDriver: Waits

    These days most of the web apps are using AJAX techniques. When a page is loaded to browser, the ele ...

  10. [c++面试准备]--vector对象是如何增长的

    参考资料:cpp primer 5th 背景: 为了支持快速的访问,vector/string将元素连续存储--每个元素都是紧挨着前一个元素存储. 如果我们向vector/string中添加新的元素, ...