@@ -0,0 +1,1275 @@
+public class Solution %7B%0A    public String fractionToDecimal(int numerator, int denominator) %7B%0A        String result = %22%22;%0A        int pn = 0;%0A        long n, dn, r;%0A        if(denominator == 0)%7B%0A            return %22%22;%0A        %7Delse if((numerator %3C 0 && denominator %3E 0) %7C%7C (numerator %3E 0 && denominator %3C 0))%7B%0A            result += %22-%22;%0A        %7D%0A        n = Math.abs((long)numerator);%0A        dn = Math.abs((long)denominator);%0A        r = n %25 dn;%0A        n = n / dn;%0A        int flag = 0;%0A        int start = 0;%0A        result += n;%0A        if(r != 0)%7B%0A            result += %22.%22;%0A            HashMap%3CLong, Integer%3E hm = new HashMap%3CLong, Integer%3E();%0A            int i = 0;%0A            while(r != 0)%7B%0A                r *= 10;%0A                if(hm.containsKey(r))%7B%0A                    flag = 1;%0A                    start = hm.get(r);%0A                    break;%0A                %7Delse%7B%0A                    hm.put(r, i);%0A                %7D%0A                n = r / dn;%0A                result += n;%0A                r %25= dn;%0A                i++;%0A            %7D%0A            if(flag == 1)%7B%0A                result = result.substring(0, result.indexOf(%22.%22) + 1 +start) + %22(%22 + result.substring(result.indexOf(%22.%22) + 1 +start) + %22)%22;%0A            %7D%0A        %7D%0A        return result;%0A    %7D%0A%7D

Q166 Fraction to Recurring Decimal