题意:有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;
}

  

最新文章

  1. [LeetCode] Binary Tree Zigzag Level Order Traversal 二叉树的之字形层序遍历
  2. ubuntu下安装加装DNS
  3. IOS textView获取光标定位,以及选中
  4. Css定位总结
  5. Git工作流指南:集中式工作流
  6. 基于.net mvc的校友录(源程序)
  7. 写一个函数,将一个int型的数组做为参数传入,使用指针返回两个结果:最大值和最小值
  8. Error:Could not open initscript class cache for initialization script &#39;C:\Users\Avishek\AppData\Local\Temp\asLocalRepo14.gradle&#39; (C:\Users\Avishek.gradle\caches\2.2.1\scripts\asLocalRepo14_dkwbdtenxxg
  9. Android 系统移植与驱动开发--第二章搭建Android环境核心步骤及心得
  10. DropDownList获取的SelectIndex一直为0
  11. 发布Qt Quick桌面应用程序的方法
  12. 接口post +json +bean
  13. 35.Linux-分析并制作环形缓冲区
  14. promise 和 async 的用法
  15. angular2^ typescript 将 文件和Json数据 合并发送到服务器(1.客户端处理)
  16. Java导出压缩包工具类
  17. [Swift]LeetCode980. 不同路径 III | Unique Paths III
  18. 用StyleCop规范团队代码
  19. In order to use an interrupt in a Cortex-M3/M4, you need the following
  20. Visual Studio 2012连接TFS2010登录不了

热门文章

  1. Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)D(树状数组)
  2. Synchronized用于线程间的数据共享,而ThreadLocal则用于线程间的数据隔离。
  3. IDEA中找不到spring的配置文件,或者不存在某个目录(比如没有src 目录)
  4. mysql5.7 忘记root密码修改方式
  5. Immediate Decodability[UVA644](Trie入门)
  6. nginx 安装部署前篇
  7. 解题报告:luogu P1516 青蛙的约会
  8. 搭建solr集群的时候出现 ./zkcli.sh:行13: unzip: 未找到命令
  9. 关于MySQL连接Navicat Premium 12失败的解决方法
  10. 手写MQ框架(四)-使用netty改造梳理