Circum Triangle - UVa 11186
来源:互联网 发布:单身 寂寞 知乎 编辑:程序博客网 时间:2024/06/10 14:54
Circum Triangle
Input: Standard Input
Output: Standard Output
You will be given N distinct points on the boundary of a circle whose center is at the origin. As the points are on the same circle no three of them are collinear, so any three of them creates a valid triangle. Your job is to find the summation of areas of these nc3 triangles.
Input
Input file contains at most 16 sets of inputs. The description of each set is given below:
Each set starts with two integers N (0 ≤ N ≤ 500) and R(0<R ≤ 100). Here N is the number of points and R is the radius of the circle. You can assume that the center of the circle is always at the origin. This line is followed by N lines each of which contains a floating-point number theta (0.0<=theta<360.00) which actually denotes the angle in degree the designated point creates with respect to the origin with x-axis. So for example if theta is 30.00 degree then the Cartesian coordinate of the intended point is (and. Assume that pi=2cos-1(0).
Input is terminated by a set where the value of N and R is zero. This set should not be processed.
Output
For each line of input produce one line of output. This line contains an integer number which is the total area (rounded to nearest integer) of all possible triangles formed by the given N points. The judge data will be such that small precision errors will not cause the output to be different. Consider at least double-precision floating numbers to do your calculations.
Sample Input Output for Sample Input
5 10
10.00
100.00
300.00
310.00
320.00
3 20
10.00
100.00
300.00
0 0
286
320
题意:输出所有三角形的面积和。
思路:暴力即可。
AC代码如下:
#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;int n;double R,sum,d,x[510],y[510],pi=3.14159265358979;double x_1,x_2,y_1,y_2;int main(){ int i,j,k; while(~scanf("%d%lf",&n,&R) && n) { sum=0; for(i=1;i<=n;i++) { scanf("%lf",&d); x[i]=R*cos(d/180*pi); y[i]=R*sin(d/180*pi); } for(i=1;i<=n;i++) for(j=i+1;j<=n;j++) { x_1=x[j]-x[i]; y_1=y[j]-y[i]; for(k=j+1;k<=n;k++) { x_2=x[k]-x[i]; y_2=y[k]-y[i]; sum+=abs(x_1*y_2-x_2*y_1)/2; } } printf("%.0f\n",sum); }}
- uva 11186 - Circum Triangle
- Circum Triangle - UVa 11186
- UVA - 11186-Circum Triangle
- UVA 11186(p349)----Circum Triangle
- Circum Triangle - UVa 11186 三角形面积
- uva 11186 - Circum Triangle(几何)
- Circum Triangle UVA
- UVa 11186 Circum Triangle 圆周上的三角形面积之和
- UVA 11186 - Circum Triangle(圆上三角形求法)
- UVA 11186 - Circum Triangle(计算几何+容斥)
- 习题10-39 UVA 11186 Circum Triangle圆周上的三角形
- UVa 488 Triangle Wave
- Uva 488 Triangle Wave
- UVa Triangle Wave
- UVA 488 - Triangle Wave
- uva-488 - Triangle Wave
- uva 11437 Triangle Fun
- UVA 11401 Triangle Counting
- 什么样的企业造什么样的软件最容易成功?
- 【Visual C++】游戏开发笔记四十五 浅墨DirectX教程十三 深度测试和Z缓存专场
- 【Visual C++】游戏开发笔记四十六 浅墨DirectX教程十四 模板测试与镜面特效专场
- Linux系统编程(13)——Shell的基本语法
- 【Visual C++】游戏开发笔记四十七 浅墨DirectX教程十五 翱翔于三维世界:摄像机的实现
- Circum Triangle - UVa 11186
- HDU 4821 String
- 【Visual C++】游戏开发四十八 浅墨DirectX教程十六 三维地形系统的实现
- Direct2D随笔1——构建D2D环境
- SQL Server 2000 数据库日志太大!如何管理,清除,变小,压缩它
- Objective-C -深浅复制
- 环境变量Path的诡异问题
- HDU 2473 Junk-Mail Filter 删点并查集
- 【Visual C++】游戏开发四十九 浅墨DirectX教程十七 三维天空的实现