5 solutions
- 
  0
这道题难在求Π的精度问题;
刚开始一直用Π=1-(1/3)+(1/5)....的公式计算精度,但是我写的代码直接超时,要不然就是精度不够。。。
所以以后求Π使用第二种方法:
通过三角函数:atan(1.0)=Π/4,结果乘4得Π!!
#include <stdio.h> #include <algorithm> #include <math.h> int main() { int x,y; double pi=atan(1)*4,k=1,q=1.0/k; int tmp=-1; scanf("%d",&x); double s=pi*x*x; printf("%.7lf\n",s); return 0; } 
- 1
 
Information
- ID
 - 36
 - Time
 - 1000ms
 - Memory
 - 256MiB
 - Difficulty
 - 7
 - Tags
 - # Submissions
 - 2193
 - Accepted
 - 422
 - Uploaded By