Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:用double不行啊,谁用double AC了 给我看看?In Reply To:用double不行啊,谁用double AC了 给我看看? Posted by:hongxingxiaonan at 2012-06-11 17:20:28 用double,不用任何技巧算法之类的0ms水过看看哈! #include<iostream> #include<Cstdio> #include<string> using namespace std; double cal(double x1, double x2) { double res1 = 1, tmp1 = x1 ,tmp2 = 1, lim2, lim1; if(x1 > 2 * x2 + 0.1) { lim1 = x1 - x2 + 0.9; lim2 = x2 + 0.01; } else { lim1 = x2 + 0.9; lim2 = x1 - x2 + 0.01; } while(tmp1 > lim1) { res1 = tmp1 * res1; tmp1 = tmp1 - 1; if(tmp2 < lim2) { res1 = res1 / tmp2; tmp2 = tmp2 + 1; } } while(tmp2 < lim2) { res1 = res1 / tmp2; tmp2 = tmp2 + 1; } return res1; } int main() { double a1, a2; long long result; while(1) { cin >> a1 >> a2; if(a1 < 0.5 && a2 < 0.5) break; result = (long long)cal(a1, a2); cout << result << endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator