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 |
突发奇想 将中间结果放在几个double里面 最后相乘double work (double &p, double &q, double &r, double &s) { double res[5], result = 1.0;//因为最后结果不超过double //那么要是res一个不够放,我就用五个res 分别将乘出来的结果放在五个res里面 //最后再将五个res乘到result里面 …… …… …… for (i = (int)q, j = (int)s; ; i--, p -= 1, j--, r -= 1) { res[(j + i)%5] *= (p / i) / (r / j);//将结果放在这里 if (j == 1 && i == 1) break; if (j == 1) { j++; r = 2; } if (i == 1) { i++; p = 2; } } for (i = 0; i < 5; i++) result *= res[i];//最后相乘 return result;//如果你觉得五个也不能放 那么就用100个double 要是还是不过 //1000个 10000个 都可以 } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator