SGU 417 Heavy Disc(眼力题)

417. Heavy Disc
Time limit per test: 0.5 second(s) 
Memory limit: 262144 kilobytes
input: standard 
output: standard



Consider a heavy disc on the plane, centered at (  x   0 y   0 ) with radius  r , with the origin strictly outside it. The density of the disc is given by formula 

 

What is the mass of the disc? 

Input
The input file contains three integer numbers  x   0 y   0 r  (-100 ≤  x   0 y   0  ≤ 100, 1 ≤  r  ≤ 100,  x   0   2 y   0   22 ). 

Output
Output one real number — the mass of the disc. Your answer will be considered correct if it is within 10  -12  relative error of the exact answer. 

Example(s)
sample input
sample output
3 4 2
40.449586576894895

【题解】

 这道题,真的是,,眼力好的6分钟出来,眼里差的2小时都化简不出来。

题意是这样的:有一个圆,告诉圆心坐标和半径,现在要然你求圆心处的密度,当然,这里的正规算法是要积分化简的,但是!!!看样例。

 根据样例,知道圆心坐标,你总要套用题目中给的公式的,套用结果大概是3点多,但是输出的答案是40点多,大概一除,结果是12点多,这和题有什么关系呢?再想想,它是个圆,不外乎周长面积,周长一算,对不上,在算面积,正好12点多,完全对上,不信的话在验证一下,没毛病,就这么简单,也不用积分化简。

 这里注意了,ln函数可以直接用log来算,很方便。


【AC代码】

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<math.h>
#include<cmath>
using namespace std;
const int N = 200;
const double PI = 3.1415926535898;//这里注意精度要大于10^-12次方

int main()
{
    int m,n,r;
    while(~scanf("%d%d%d",&m,&n,&r))
    {
        double x = log(m*m+n*n);
        x *= r*r*PI;
        printf("%.12f\n",x);
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值