Advertisement
amine99

Untitled

Feb 17th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define loop(i,b,e) for(int i=b;i<=e;i++)
  4. #define reloop(i,e,b) for(int i=e;i>=b;i--)
  5. typedef long long ll;
  6.  
  7. int const N=1e5+10;
  8. ll n,k,t[N],m=1e18+1,type,cont;
  9.  
  10. int main() {
  11.    ios_base::sync_with_stdio(false);
  12.     cin.tie(0);
  13.     cout.tie(0);
  14.     cin >> n >> k;
  15.     loop(i,1,k) {
  16.       cin >> t[i];
  17.       if (n % t[i] == 0 && n >= t[i]) {
  18.          cout << i << " " << n/t[i];
  19.          return 0;
  20.       }
  21.       if (n % t[i] < m && n >= t[i]) {
  22.          m = n % t[i];
  23.          type = i;
  24.          cont=n/t[i];
  25.       }
  26.     }
  27.     if (type==0) {
  28.       type = 1;
  29.       cont = 0;
  30.     }
  31.     cout << type << " " << cont;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement