Codeforces Round #464 (Div. 2) B. Hamster Farm
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
解题心得:
- 题意是一个农夫有n只仓鼠,k中笼子,每种笼子可以装Ki只仓鼠,只有笼子装满才能将仓鼠带走,选择一种笼子,要使带走的仓鼠最多,问最少要多少个笼子。
- 暴力,每次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的更多相关文章
- 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 ...
- Codeforces Round #464 (Div. 2)
A. Love Triangle time limit per test: 1 second memory limit per test: 256 megabytes input: standard ...
- Codeforces Round #464 (Div. 2) E. Maximize!
题目链接:http://codeforces.com/contest/939/problem/E E. Maximize! time limit per test3 seconds memory li ...
- Codeforces Round #464 (Div. 2) D. Love Rescue
D. Love Rescue time limit per test2 seconds memory limit per test256 megabytes Problem Description V ...
- Codeforces Round #464 (Div. 2) C. Convenient For Everybody
C. Convenient For Everybody time limit per test2 seconds memory limit per test256 megabytes Problem ...
- Codeforces Round #464 (Div. 2) A Determined Cleanup
A. Love Triangle time limit per test1 second memory limit per test256 megabytes Problem Description ...
- 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 ...
- Codeforces Round #464 (Div. 2) D题【最小生成树】
Valya and Tolya are an ideal pair, but they quarrel sometimes. Recently, Valya took offense at her b ...
- 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 ...
随机推荐
- Mercurial(HG) Windows+Eclipse安装、配置、使用
Mercurial(HG) Windows客户端安装 Mercurial(HG): http://mercurial.selenic.com/ Windows客户端下载:http://mercuria ...
- Cmder 简明使用说明
简介 Cmder is a software package created out of pure frustration over the absence of nice console emul ...
- Aspx 验证码_各种封装
验证码 namespace CZBK.TestProject.Common { public class ValidateCode { public ValidateCode() { } /// &l ...
- 使用Pycharm开发python下django框架项目生成的文件解释
目录MyDjangoProject下表示工程的全局配置,分别为setttings.py.urls.py和wsgi.py,1.其中setttings.py包括了系统的数据库配置.应用配置和其他配置,2. ...
- Laravel事件监听器listener与事件订阅者Subscriber的区别
其实就一句话: Each event can have multiple listeners, but a listener can't listen to more than a single ev ...
- 大数四则运算java(转)
// 大数的四则运算 #include <iostream> #include <string> #include <algorithm> using namesp ...
- crontab配置shell实现后台进程不间断运行
检测get_report_no.php进程是否一直在运行 #!/bin/bash PROC=`ps -ef |grep get_report_no.php|grep -v grep|wc -l` if ...
- 【转】android调试工具DDMS的使用详解
具体可见http://developer.android.com/tools/debugging/ddms.html. DDMS为IDE和emultor.真正的android设备架起来了一座桥梁.开发 ...
- [超详细] Python3爬取豆瓣影评、去停用词、词云图、评论关键词绘图处理
爬取豆瓣电影<大侦探皮卡丘>的影评,并做词云图和关键词绘图第一步:找到评论的网页url.https://movie.douban.com/subject/26835471/comments ...
- 我的Linux学习之路的感悟
首先要跟大家说声抱歉,这么久一直没有更新,有负大家对我的期望. 半年的Linux运维的学习到目前已工作一个月零9天,这一路走来的艰辛和挣扎只有自己最清楚. 首先要感谢公司的同事的宽容接纳和耐心指点.感 ...