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 |
WA了好几次,竟然是因为e和pi的精确度不够#include <stdio.h> #include <math.h> #define e 2.7182818284590452354 #define pi 3.141592653589793239 int main() { int n,m,i,b; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&m); if(m==1) b = 1; else b = m*log10(m/e) + log10(2*pi*m)/2 + 1; printf("%d\n",b); } return 0; } 之前,e和pi的位数都取小数点后五位,发现对于很多数结果是错的。 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator