public String exchange(String cur, int target) {
      int curind = names.get(cur);
      double min = Double.MAX_VALUE;
      String result = null;
      for (Entry<String, Integer> currency : names.entrySet()) {
        if (!currency.getKey().equals(cur)) {
          double rate = search(curind, currency.getValue());
          if (rate != 0) {
            int needed = Math.min((int) Math.ceil(target * rate - 0.0001), 100000);
            if (needed / rate + 0.0001 >= target) {
              double diff = needed / rate - (double) target + 0.0001;          
              if (diff < min) {
                min = diff;
                result = needed + " " + currency.getKey();
              }
            }
          }
        }
      }
      return result;
    }