HDU 6055 组合正多边形问题
2017-07-27 19:02
232 查看
Regular polygonTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 220 Accepted Submission(s): 86 Problem Description On a two-dimensional plane, give you n integer points. Your task is to figure out how many different regular polygon these points can make. Input The input file consists of several test cases. Each case the first line is a numbers N (N <= 500). The next N lines ,each line contain two number Xi and Yi(-100 <= xi,yi <= 100), means the points’ position.(the data assures no two points share the same position.) Output For each case, output a number means how many different regular polygon these points can make. Sample Input 4 0 0 0 1 1 0 1 1 6 0 0 0 1 1 0 1 1 2 0 2 1 Sample Output 1 2 Source 2017 Multi-University Training Contest - Team 2 |
所以只要枚举两个点,旋转90度去找另外两个点是否存在,最后答案除4就可以了
#include<bits/stdc++.h> using namespace std; #define MAXN 800 struct point{ int x,y; }p[MAXN]; int ans; int has[MAXN][MAXN]; point change(point a,point b){ int x = a.x - b.x; int y = a.y - b.y; struct point c; c.x = b.x - y; c.y = b.y + x; return c; } bool isHas(point a){ if(has[a.x][a.y]) return true; return false; } bool solve(int i,int j){ point a = p[i]; point b = p[j]; point c = change(a,b); point d = change(b,c); if(isHas(c) && isHas(d)) return true; return false; } int main(){ int n; while(scanf("%d",&n) != EOF){ memset(has,0,sizeof(has)); for(int i = 1;i <= n;i++){ scanf("%d %d",&p[i].x,&p[i].y); p[i].x += 300; p[i].y += 300; has[p[i].x][p[i].y] = 1; } ans = 0; for(int i = 1;i <= n;i++){ for(int j = 1;j <= n;j++){ if(i != j && solve(i,j)){ ans++; } } } printf("%d\n",ans / 4); } return 0; }
相关文章推荐
- Shape of HDU 几何问题判断多边形凹凸性
- HDU 2519 新生晚会(组合问题)
- 多边心重心[nyoj 3 多边形重心问题, hdu 1115 Lifting the Stone]
- HDU 25919 新生晚会(水题组合问题)
- hdu 1115(多边形重心问题)
- HDU 5719Arrange(类似排列组合问题)
- hdu 2036 改革春风吹满地 求多边形面积问题
- HDU 1756 Cupid's Arrow (几何问题,判定点在多边形内部)
- 组合数学第二发 错排问题 hdu 2049 + hdu 2068
- HDU 4000 Fruit Ninja (树状数组+组合问题)
- *寒假水76——Shape of HDU 【判断凹凸多边形问题】
- 手机按键组合问题
- HDU 3790 最短路径问题【多关键字最短路,Dijkstra算法+spfa算法】
- HDU 2181 哈密顿绕行世界问题
- HDU - 4810 Wall Painting(组合数学)
- hdu 5418 Victor and World 状态压缩dp,旅行商问题
- hdu 1210 Eddy's 洗牌问题
- hdu 1242 Rescue 优先队列问题
- HDU_1016——素环问题DFS
- 算法学习-组合问题递归解法