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 ...
随机推荐
- ssm 框架 使用ajax异步,实现登陆
只是简单写一下 js.jsp.和controller jsp <%@ page contentType="text/html;charset=UTF-8" language= ...
- SICP题解
这里用Common Lisp.Haskell等函数式语言. 1.2.请将下面表达式变换为前缀形式: $$ \frac{5 + 4 + (2 - (3 - (6 + \frac{4}{5})))}{3( ...
- springcloud-zuul进阶篇
一 前言 经过zuul初级篇(博客或者公主号springcloud专栏可以找到)的学习,读者都懂得如何简单的使用zuul进行路由网关配置,在进阶篇中你将获得zuul核心功能过滤器的基本使用,通过zuu ...
- mysql path妙用
CREATE TABLE `lc_c_user_path` ( `id` INT ( ) UNSIGNED NOT NULL AUTO_INCREMENT, `user_id` VARCHAR ( ) ...
- Spring Cloud入门-Nacos实现注册和配置中心(Hoxton版本)
文章目录 摘要 Nacos简介 使用Nacos作为注册中心 安装并运行Nacos 创建应用注册到Nacos 负载均衡功能 使用Nacos作为配置中心 创建nacos-config-client模块 在 ...
- Java实现图片内容无损任意角度旋转
转自:http://blog.csdn.net/heliang7/article/details/7309394 主要问题是如何在图片做旋转后计算出新图片的长宽. 在java 2d和基本math库的帮 ...
- 【快学springboot】3.多种接受参数的方式
前往掘金查看:https://juejin.im/post/5d05e5f9f265da1b6c5f74b4 前言 在开发中,我们常常会碰到多种传参的方式.这里,我们就来总结下,springboot中 ...
- 使用 sp_attach_db 系统存储过程附加数据库时---转载
//附加数据库 sp_attach_db 当使用 sp_attach_db 系统存储过程附加数据库时. sp_attach_db:将数据库附加到服务器. 语法 sp_attach_db [ @dbna ...
- Laradock 开放 workspace 端口
1.在 laradock/workspace/Dockerfile 文件的最后添加一行,申明开放端口: EXPOSE 1215; 2.在 laradock/docker-compose ...
- SC.Lab3对于Factory的构建过程(from HIT)
Factory设计模式基本就是通过传入指定的参数/或者不传入参数,通过Factory的某个方法(为了避免实例化Factory对象,一般方法为静态static),来获取一个对象.这个是Factory用的 ...