Advertisement
amine99

Untitled

Feb 17th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 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+1;
  8. ll n,k,t[N],m=1e18,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] < m && n >= t[i]) {
  18.          m = n % t[i];
  19.          type = i;
  20.          cont=t[i];
  21.       }
  22.     }
  23.     if (type==0)
  24.       type++;
  25.     cout << type << " " << cont;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement