zoj 1974 || poj 1940 Polygon Programming with Ease
2011-05-01 14:14
357 查看
1973是给出顶点求中点,这个是给出中点求顶点。
和会升讨论了下,发现可以用一个顶点去替代所有顶点,然后解方程。后来我发现,如果是偶数点的话,最后那个顶点的坐标被消去了!不过还好,给的是奇数个顶点。偶数边的话,结果是不唯一的,自己手动模拟下就知道啦。
和会升讨论了下,发现可以用一个顶点去替代所有顶点,然后解方程。后来我发现,如果是偶数点的话,最后那个顶点的坐标被消去了!不过还好,给的是奇数个顶点。偶数边的话,结果是不唯一的,自己手动模拟下就知道啦。
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream> #include <algorithm> #include <queue> #include <stack> #include <math.h> using namespace std; const int MAX = 1010; struct point{ double x,y;}; point p[MAX]; double disp2p(point a,point b) { return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y)); } point s[MAX]; int main() { int n; while( ~scanf("%d",&n) ) { for(int i=0; i<n; i++) scanf("%lf %lf",&p[i].x,&p[i].y); double sumy = 0.0,sumx = 0.0; for(int i=0; i<n; i++) if( i % 2 == 0 ) { sumx += p[i].x; sumy += p[i].y; } else { sumx -= p[i].x; sumy -= p[i].y; } s[0].x = sumx; s[0].y = sumy; printf("%d %.6lf %.6lf",n,s[0].x,s[0].y); for(int i=1; i<n; i++) { s[i].x = 2*p[i-1].x-s[i-1].x; s[i].y = 2*p[i-1].y-s[i-1].y; printf(" %.6lf %.6lf",s[i].x,s[i].y); } printf("/n"); } return 0; }
相关文章推荐
- POJ 1940 Polygon Programming with Ease 笔记
- POJ 1940 Polygon Programming with Ease(高斯消元)
- POJ 1940 Polygon Programming with Ease(给出线段中点求端点+解简单方程)
- hdu 2462 poj 3696 The Luckiest number fzu 1017 zoj 1537 Playing with Calculator
- POJ 1974和ZOJ 2499题解
- POJ 2251 Dungeon Master /UVA 532 Dungeon Master / ZOJ 1940 Dungeon Master(广度优先搜索)
- zoj 1940 || poj 2251 Dungeon Master
- zoj 1940 || poj 2251 Dungeon Master(bfs)
- !POJ 2251 & ZOJ 1940--BFS(第一道BFS)
- The study of Programming Windows with MFC-printing tips
- POJ 1060/ ZOJ 1026 : Modular Multiplication of Polynomials - f(x)g(x) mod h(x)
- DirectX10 学习1(摘录Introduction to 3D Game Programming with DirectX 10(中文版))
- POJ 2299 && ZOJ 2386 Ultra-QuickSort 线段树
- zoj 1718 poj 2031 Building a Space Station
- POJ 1005 & ZOJ 1049 & UVA 2363
- Learning Linux(6): Programming with shell
- 《Excel 2013 Power Programming with VBA》部分章节译文
- POJ 3468 A Simple Problem with Integers(线段树区间修改)
- CORBA Programming with TAO - 1.Start(基本概念)
- 经典动态规划问题 背包问题 [POJ3211][POJ2063][HDU1114][POJ1276][POJ1014][POJ1742][ZOJ3631]