SGU 417Heavy Disc(眼力题)
来源:互联网 发布:伊利大数据雷达 编辑:程序博客网 时间:2024/04/27 19:22
417. Heavy Disc
Time limit per test: 0.5 second(s)
Memory limit: 262144 kilobytes
Memory limit: 262144 kilobytes
input: standard
output: 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
- SGU 417Heavy Disc(眼力题)
- SGU 417. Heavy Disc(水题)
- DISC 免费性格测试题
- DISC社交风格测试题--老虎 孔雀 考拉 猫头鹰
- DISC定义
- SGU
- SGU
- SGU
- SGU
- SGU
- SGU
- (SGU
- SGU
- SGU
- SGU
- SGU
- SGU
- SGU
- (int)a,&a,(int)&a,(int&)a区别
- PAT1019 数字黑洞
- 杭电ACM OJ 1022 Train Problem I 回溯法求出栈遍历序列 很强大
- Python笔记(按做题时认知先后排序)
- 11月16日笔记
- SGU 417Heavy Disc(眼力题)
- 六款互联网人不容错过的软件神器
- 沃舍尔算法【离散数学作业大杀器】
- postgres 事务
- 4412芯片---跑马灯小实验
- java线程安全之多线程的设计模式(十四)
- 最大子段和问题的四种算法(暴力法、优化后的暴力法、分治算法、动态规划算法)
- postgres 窗口函数
- __weak与__block区别,深层理解两者区别