Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define loop(i,b,e) for(int i=b;i<=e;i++)
- #define reloop(i,e,b) for(int i=e;i>=b;i--)
- typedef long long ll;
- int const N=1e5+10;
- ll n,k,t[N],m=1e18+1,type,cont;
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- cin >> n >> k;
- loop(i,1,k) {
- cin >> t[i];
- if (n % t[i] == 0 && n >= t[i]) {
- cout << i << " " << n/t[i];
- return 0;
- }
- if (n % t[i] < m && n >= t[i]) {
- m = n % t[i];
- type = i;
- cont=n/t[i];
- }
- }
- if (type==0) {
- type = 1;
- cont = 0;
- }
- cout << type << " " << cont;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement