UVA - 11186 Circum Triangle (几何)
题意:有N个点,分布于一个圆心在原点的圆的边缘上,问所形成的所有三角形面积之和。
分析:
1、sin的内部实现是泰勒展开式,复杂度较高,所以需预处理。
2、求出每两点的距离以及该边所在弧所对应的圆周角。一条弧所对圆周角等于它所对圆心角的一半。
3、S = 1/2*absinC求三角形面积即可。
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<sstream>
#include<iterator>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<list>
#define lowbit(x) (x & (-x))
const double eps = 1e-8;
inline int dcmp(double a, double b){
if(fabs(a - b) < eps) return 0;
return a > b ? 1 : -1;
}
typedef long long LL;
typedef unsigned long long ULL;
const int INT_INF = 0x3f3f3f3f;
const int INT_M_INF = 0x7f7f7f7f;
const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
const int MOD = 1e9 + 7;
const double pi = acos(-1.0);
const int MAXN = 500 + 10;
const int MAXT = 10000 + 10;
using namespace std;
int N;
double R;
double Sin[MAXN][MAXN];
double dist[MAXN][MAXN];
struct Node{
double x, y, rad;
void read(){
scanf("%lf", &rad);
rad = rad / 180.0 * pi;
x = R * cos(rad);
y = R * sin(rad);
}
}num[MAXN];
double getDist(int i, int j){
return sqrt((num[i].x - num[j].x) * (num[i].x - num[j].x) + (num[i].y - num[j].y) * (num[i].y - num[j].y));
}
int main(){
while(scanf("%d%lf", &N, &R) == 2){
if(N == 0 && R == 0) return 0;
memset(Sin, 0, sizeof Sin);
memset(dist, 0, sizeof dist);
for(int i = 0; i < N; ++i){
num[i].read();
}
for(int i = 0; i < N; ++i){
for(int j = i + 1; j < N; ++j){
Sin[i][j] = sin(fabs(num[j].rad - num[i].rad) / 2.0);
dist[i][j] = dist[j][i] = getDist(i, j);
}
}
double sum = 0.0;
for(int i = 0; i < N; ++i){
for(int j = i + 1; j < N; ++j){
for(int k = j + 1; k < N; ++k){
sum += dist[i][j] * dist[i][k] * Sin[j][k] / 2;
}
}
}
double ans = round(sum);
printf("%.0lf\n", ans);
}
return 0;
}
UVA - 11186 Circum Triangle (几何)的更多相关文章
- uva 11186 Circum Triangle<叉积>
链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVA 11186 Circum Triangle (枚举三角形优化)(转)
题意:圆上有n个点,求出这n个点组成的所有三角形的面积之和 题解: 当我们要求出S(i,j,k)时,我们需要假设k在j的左侧,k在i与j之间,k在i的右侧. 如果k在 j的左侧 那么 S(i,j,k ...
- UVa OJ 194 - Triangle (三角形)
Time limit: 30.000 seconds限时30.000秒 Problem问题 A triangle is a basic shape of planar geometry. It con ...
- A. Srdce and Triangle 几何题
链接:https://www.nowcoder.com/acm/contest/104/A来源:牛客网 题目描述 Let be a regualr triangle, and D is a poin ...
- UVA 11796 Dog Distance(几何)
Dog Distance [题目链接]Dog Distance [题目类型]几何 &题解: 蓝书的题,刘汝佳的代码,学习一下 &代码: // UVa11796 Dog Distance ...
- UVa 11971 - Polygon(几何概型 + 问题转换)
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- UVa 11346 - Probability(几何概型)
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- uva 11178二维几何(点与直线、点积叉积)
Problem D Morley’s Theorem Input: Standard Input Output: Standard Output Morley’s theorem states tha ...
- uva 11665 Chinese Ink (几何+并查集)
UVA 11665 随便给12的找了一道我没做过的几何基础题.这题挺简单的,不过uva上通过率挺低,通过人数也不多. 题意是要求给出的若干多边形组成多少个联通块.做的时候要注意这题是不能用double ...
随机推荐
- 一步一步配置docker(tomcat+jenkins+phpmyadmin+nginx)
经过半个月的docker学习实践,今天对自己的学习成果做个总结. 貌似官方推荐的是docker compose使用DockerFile 来配置,但目前还没学习使用docker compose,先学习通 ...
- 「Luogu4556」Vani有约会-雨天的尾巴
「Luogu4556」Vani有约会-雨天的尾巴 传送门 很显然可以考虑树上差分+桶,每次更新一条链就是把这条链上的点在桶对应位置打上 \(1\) 的标记, 最后对每个点取桶中非零值的位置作为答案即可 ...
- Spring Boot+Jpa(MYSQL)做一个登陆注册系统(前后端数据库一站式编程)
Spring Boot最好的学习方法就是实战训练,今天我们用很短的时间启动我们第一个Spring Boot应用,并且连接我们的MySQL数据库. 我将假设读者为几乎零基础,在实战讲解中会渗透Sprin ...
- uniGUI之TUniHiddenPanel(14)
TUniHiddenPanel是将不在界面上显示的 容器 控件. 只有uniDBGrid实际列才有对应的编辑控件,如果是外键列则无法设置 编辑控件. 里面的控件将不会 显示.将控件放入其中即可. ...
- Python中property属性的概论和使用方法
property属性 概念: 定义一个方法但是使用装饰器property,只可以有一个self形参 可以用这样的属性动态的获取属性的值 定义方式(经典类) class Fun(): @property ...
- 一定要熟练地使用常用的Foundation服务
关于本文:作为一名iOS软件工程师,熟练的使用系统提供的强大的Foundation服务是必备的职业素养. NSString.NSMutableString NSArray.NSMutableStrin ...
- Django线上部署代码修改失效问题
记一次django项目的线上部署维护问题,django+nginx 关于nginx反向代理服务器的介绍这里有一篇博客介绍的比较好:nginx的相关介绍 以及当一次客户端请求发出后,uwsig以及uWS ...
- postgresql shell脚本传递参数并执行sql脚本并
参考: https://stackoverflow.com/questions/7389416/postgresql-how-to-pass-parameters-from-command-line ...
- cgpwn2-嫖来的wp
本想练习pwn的题目活跃下思维,但是接触后发现完全不懂,gg 然后就多方搜集,弄来了一些工具(IDA pro.pwntool)结果自己还是不会用,又是一番刷视频,结果看完又是一脸懵. 只记得一个快捷键 ...
- java并发AtomicReference
java并发AtomicReference AtomicReference的作用 已经介绍过AtomicInteger,AtomicIntegerArray,AtomicReference是针对对象的 ...