首页 > 其他 > 详细

fzu 1330:Center of Gravity(计算几何,求扇形重心)

时间:2014-04-10 04:14:18      阅读:945      评论:0      收藏:0      [点我收藏+]
Problem 1330 Center of Gravity

Accept: 443    Submit: 830
Time Limit: 1000 mSec    Memory Limit : 32768 KB

bubuko.com,布布扣 Problem Description

Given a sector of radius R, central angle P. You are to calculate the distance between the center of gravity and the center of the circle.

bubuko.com,布布扣 Input

Given a sector of radius R, central angle P. You are to calculate the distance between the center of gravity and the center of the circle.

bubuko.com,布布扣 Output

Given a sector of radius R, central angle P. You are to calculate the distance between the center of gravity and the center of the circle.

bubuko.com,布布扣 Sample Input

0.01 6.28

bubuko.com,布布扣 Sample Output

0.000003

 
  计算几何,求扇形的重心
  看的教程里有求扇形重心的公式,我就直接拿来用了:
  bubuko.com,布布扣
  
  可以看出,这里求的重心位置是重心到圆心的距离,正好是这道题求得值。
  代码
bubuko.com,布布扣
 1 #include <stdio.h>
 2 #include <math.h>
 3 int main()
 4 {
 5     double r,p;
 6     while(scanf("%lf%lf",&r,&p)!=EOF){
 7         double z;    //扇形重心
 8         p/=2;
 9         // 求扇形重心公式一
10         //double b = r*sin(p);    //圆心角对应的弦长
11         //double s = p*r;        //圆心角对应的弧长
12         //z = 2*r*b/(3*s);
13         //公式二
14         z = 2*r*sin(p)/(3*p);
15         printf("%lf\n",z);
16     }
17     return 0;
18 }
bubuko.com,布布扣

   PS:公式一是公式二的推导后的公式。

 

Freecode : www.cnblogs.com/yym2013

fzu 1330:Center of Gravity(计算几何,求扇形重心),布布扣,bubuko.com

fzu 1330:Center of Gravity(计算几何,求扇形重心)

原文:http://www.cnblogs.com/yym2013/p/3654778.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!