HDU 1115 Lifting the Stone
来源:互联网 发布:面试php基础知识 编辑:程序博客网 时间:2024/06/04 07:35
PS: 几何基础,求解多边形重心问题。
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <vector>#include <cmath>using namespace std;struct point{ double x, y; point(double x=0, double y=0):x(x), y(y) {}};point operator - (point A, point B) { return point(A.x-B.x, A.y-B.y);}double Cross(point A, point B) { return A.x*B.y - A.y*B.x;}vector<point> v;int n;int main() { int T; point tmp; scanf("%d", &T); while(T--) { scanf("%d", &n); v.clear(); for(int i = 0; i < n; i++) { scanf("%lf%lf", &tmp.x, &tmp.y); v.push_back(tmp); } point res; res.x = 0, res.y = 0; double sum = 0, det; for(int i = 1; i < n-1; i++) { det = Cross(v[i]-v[0], v[i+1]-v[0]); res.x += det*(v[0].x+v[i].x+v[i+1].x); res.y += det*(v[0].y+v[i].y+v[i+1].y); sum += det; } res.x = res.x/(sum*3); res.y = res.y/(sum*3); printf("%.2f %.2f\n", res.x, res.y); // G++, C++ } return 0;}
0 0
- HDU 1115 Lifting the Stone
- HDU 1115 Lifting the Stone
- hdu-1115-Lifting the Stone
- hdu 1115 Lifting the Stone
- HDU 1115 Lifting the Stone
- HDU 1115 Lifting the Stone
- HDU-Lifting the Stone
- HDU 1115 Lifting the Stone 计算几何
- HDU 1115 Lifting the Stone(多边形重心)
- hdu 1115 Lifting the Stone 多边形面积
- hdu 1115 Lifting the Stone (重心问题)
- 求重心-hdu-1115-Lifting the Stone
- 【多边形重心】hdu 1115 Lifting the Stone
- hdu 1115 Lifting the Stone 计算几何
- HDU 1115 Lifting the Stone(多边形重心)
- hdu 1115 Lifting the Stone【多边形重心】
- hdu 1115 Lifting the Stone【多边形重心】
- HDU 1115 Lifting the Stone (多边形重心)
- POJ 2242 The Circumference of the Circle
- 关于UIView 的autoresizingMask属性,即UIViewAutoresizing
- Word Maze 网络小游戏
- 福州大学 Problem 2168 防守阵地 I
- PHP基础学习第二讲(分支讲解)
- HDU 1115 Lifting the Stone
- ACM-计算几何之Scrambled Polygon——poj2007
- 《算法导论》笔记 第15章 总结与思考
- 让Editplus支持sql语法高亮显示
- 今天,Java编程周末提高班(第一期)正式结束
- 使用SQLPLUS生成HTML报表
- leetcode Linked List Circle
- 福州大学第十一届程序设计竞赛 部分题目题解
- 重建二叉树(剑指offer6、编程之美3.9)