标签:imp mat flow overflow code tco blog int over
A simple math.. take care of data overflow though.
class Solution { public: int arrangeCoins(int n) { if(n < 0) return -1; return sqrt((long long)2 * n + 0.25) - 0.5; } };
标签:imp mat flow overflow code tco blog int over
原文地址:http://www.cnblogs.com/tonix/p/6015090.html