Exemplo n.º 1
0
  public void solve() {
    while (input.hasNext()) {
      String s = input.nextLine();
      s = s.replaceAll("[0\\.\\)]", "");
      String[] t = s.split("\\(");
      long a = Long.valueOf(t[0]);
      long b = Long.valueOf(t[1]);

      long x = a * ((long) pow(10, t[1].length()) - 1) + b;
      long y = ((long) pow(10, t[1].length()) - 1) * (long) pow(10, t[0].length());
      System.out.println(x);
      System.out.println(y);
      System.out.printf((x / gcd(x, y)) + "/" + (y / gcd(x, y)));
    }
  }