Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: Kanan Asgarli
- https://www.e-olymp.com/az/problems/1461
- */
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int f(int n){
- if(n == 0)
- return 1;
- return n%10*f(n/10);
- }
- int n, m, k, maxi = 1000000000, ans;
- int main()
- {
- cin>>n>>k;
- for(int i = 0; i < n; i++){
- cin>>m;
- if(maxi > abs(f(m)-k)){
- maxi = abs(f(m)-k);
- ans = m;
- }
- }
- cout<<ans<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment