【题目】
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.
If the fractional part is repeating, enclose the repeating part in paren...
分类:
其他好文 时间:
2014-12-19 12:11:03
阅读次数:
172
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating,...
分类:
其他好文 时间:
2014-12-18 23:39:14
阅读次数:
381
leetcode新题,哈希表,Fraction to Recurring Decimal 。题意:给定两个整型数,一个代表分子numerator,一个代表分母denominator,以小数的形式返回它们的结果result,当有循环小数时,以括号形式表示。比如5/3=1.666666...以“1.(6)”的形式返回,返回的类型是字符串。
解题要点:
1、负数的处理
2、INT_MIN的处理,将INT_MIN转化为正数会溢出,因此要使用long long int来计算。
3、分为整数部分和小数部分,重点在于小...
分类:
其他好文 时间:
2014-12-18 09:13:48
阅读次数:
182
Fraction to Recurring DecimalGiven two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the ...
分类:
其他好文 时间:
2014-12-17 23:53:01
阅读次数:
220
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating,...
分类:
其他好文 时间:
2014-12-17 22:27:05
阅读次数:
241
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating,...
分类:
其他好文 时间:
2014-12-17 14:17:32
阅读次数:
193
一位一位的算嘛,如果出现了重复的余数那么就是循环节开始啦。用hashtable记录下位置,好插入括号。注意负数。class Solution {public: string fractionToDecimal(int numerator, int denominator) { i...
分类:
其他好文 时间:
2014-12-17 12:35:20
阅读次数:
147
Problem A: Fractions Again?!Time limit: 1 secondIt is easy to see that for every fraction in the form(k> 0), we can always find two positive integersx...
分类:
其他好文 时间:
2014-11-26 14:16:39
阅读次数:
174
1. 1 #import "Fraction.h" 2 3 @interface Fraction (MathOps) 4 5 - (Fraction *) add: (Fraction *) f; 6 7 - (Fraction *) mul: (Fraction *) f; 8 9 - ...
分类:
其他好文 时间:
2014-11-21 01:22:09
阅读次数:
139
1.各个方法的实现 1 - (Fraction *) subtract: (Fraction *) f 2 { 3 Fraction *result = [[Fraction alloc] init]; 4 5 result.numerator = numerator *f...
分类:
其他好文 时间:
2014-11-08 23:30:13
阅读次数:
462