题意:有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 (几何)的更多相关文章

  1. uva 11186 Circum Triangle<叉积>

    链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  2. UVA 11186 Circum Triangle (枚举三角形优化)(转)

    题意:圆上有n个点,求出这n个点组成的所有三角形的面积之和 题解: 当我们要求出S(i,j,k)时,我们需要假设k在j的左侧,k在i与j之间,k在i的右侧. 如果k在 j的左侧  那么 S(i,j,k ...

  3. UVa OJ 194 - Triangle (三角形)

    Time limit: 30.000 seconds限时30.000秒 Problem问题 A triangle is a basic shape of planar geometry. It con ...

  4. A. Srdce and Triangle 几何题

    链接:https://www.nowcoder.com/acm/contest/104/A来源:牛客网 题目描述 Let  be a regualr triangle, and D is a poin ...

  5. UVA 11796 Dog Distance(几何)

    Dog Distance [题目链接]Dog Distance [题目类型]几何 &题解: 蓝书的题,刘汝佳的代码,学习一下 &代码: // UVa11796 Dog Distance ...

  6. UVa 11971 - Polygon(几何概型 + 问题转换)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  7. UVa 11346 - Probability(几何概型)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  8. uva 11178二维几何(点与直线、点积叉积)

    Problem D Morley’s Theorem Input: Standard Input Output: Standard Output Morley’s theorem states tha ...

  9. uva 11665 Chinese Ink (几何+并查集)

    UVA 11665 随便给12的找了一道我没做过的几何基础题.这题挺简单的,不过uva上通过率挺低,通过人数也不多. 题意是要求给出的若干多边形组成多少个联通块.做的时候要注意这题是不能用double ...

随机推荐

  1. Web - 实用组件

    1, vue-awesome-swiper  基于 Swiper4.适用于 Vue 的轮播组件,支持服务端渲染和单页应用. 2,  http://www.spritecow.com/     雪碧图背 ...

  2. vector的clear和swap

    vector的clear()操作只是清空vector的元素,而不会将内存释放掉 vector<int> vec1{ 1,2,3,4,5 }; vec1.clear(); cout<& ...

  3. Java入门程序“hello,world!”

    1.程序开发步骤说明 开发环境已经搭建完毕,可以开发我们第一个Java程序了. Java程序开发三步骤:编写.编译.运行.(图片介绍)   2.编写Java程序 新建一个普通的记事本,给其命名为Hel ...

  4. Flask - 上下文管理(核心)

    参考 http://flask.pocoo.org/docs/1.0/advanced_foreword/#thread-locals-in-flask https://zhuanlan.zhihu. ...

  5. UIWindow的获取

    注意:还是直接用下面这个比较靠谱.尤其是iOS11之后. [UIApplication sharedApplication].keyWindow;   1.下面这种是比较严谨的方式 - (UIWind ...

  6. MongoDB in 数量限制

    1.查询语句本身其实是一个document, 最大为16MB(3.4,4.0 的限制,官方文档)2.查询语句本身,也就是{ '' : { '$in' : [] }}, 大小为 22字节3.每增加一个字 ...

  7. windows远程桌面不显示本地磁盘

    \\tsclient\D 在资源管理器输入上面的内容就可以访问本地的D盘,但是前提是连接远程桌面的时候设置了可以访问本地D盘.

  8. IdentityServer4专题之七:Authorization Code认证模式

    (1)identityserver4授权服务器端 public static class Config { public static IEnumerable<IdentityResource& ...

  9. 每个项目中,你必须知道的11个Java第三方类库。

    Java第三方library ecosystem是一个很广阔的范畴.不久前有人撰文:每个项目中,你必须知道的11个Java第三方类库. 单元测试 1.DBUnit DBunit是一个基于junit扩展 ...

  10. NPOI,导出Execl,压缩文件zip,发送Email

    private void SendEmail(string emailAddress, string companyName,string proxy, string officer, DataTab ...