Run
2015-08-10 09:22
344 查看
Run
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 736 Accepted Submission(s): 320
[align=left]Problem Description[/align]
AFA
is a girl who like runing.Today,he download an app about runing .The
app can record the trace of her runing.AFA will start runing in the
park.There are many chairs in the park,and AFA will start his runing in a
chair and end in this chair.Between two chairs,she running in a
line.she want the the trace can be a regular triangle or a square or a
regular pentagon or a regular hexagon.
Please tell her how many ways can her find.
Two ways are same if the set of chair that they contains are same.
[align=left]Input[/align]
There are multiply case.
In each case,there is a integer n(1 < = n < = 20)in a line.
In next n lines,there are two integers xi,yi(0 < = xi,yi < 9) in each line.
[align=left]Output[/align]
Output the number of ways.
[align=left]Sample Input[/align]
4
0 0
0 1
1 0
1 1
[align=left]Sample Output[/align]
1
题意:一个喜欢跑步的小女孩儿在有椅子的公园里跑步。在跑步过程中,她会有选择的在椅子上休息,给定椅子位置全是整数点坐标,问以小女孩经过的长椅位置为点可能构成的正3,4,5, 6边形的情况有几种
既然长椅位置都是整数点坐标,那么构成正多边形的情况只有正四边形。数据范围不大,20.暴搜就行。
#include<iostream> #include<algorithm> #include<cstdio> #include<cstring> using namespace std; #define N 25 int n; struct node { int x, y; }P ; int slove(int i, int j, int k, int q) //求出4点之间所有距离,会得到4个边长,和两个对角线的长度。显然只有两个不等的量,满足条件就是正四边形 { if(i == j || i == k) return false; if(i == q || j == k) return false; if(j == q || k == q) return false; int w = 0, num[8]; memset(num, 0, sizeof(num)); num[w++] = (P[i].x-P[j].x)*(P[i].x-P[j].x)+(P[i].y-P[j].y)*(P[i].y-P[j].y); num[w++] = (P[i].x-P[k].x)*(P[i].x-P[k].x)+(P[i].y-P[k].y)*(P[i].y-P[k].y); num[w++] = (P[i].x-P[q].x)*(P[i].x-P[q].x)+(P[i].y-P[q].y)*(P[i].y-P[q].y); num[w++] = (P[j].x-P[k].x)*(P[j].x-P[k].x)+(P[j].y-P[k].y)*(P[j].y-P[k].y); num[w++] = (P[j].x-P[q].x)*(P[j].x-P[q].x)+(P[j].y-P[q].y)*(P[j].y-P[q].y); num[w++] = (P[q].x-P[k].x)*(P[q].x-P[k].x)+(P[q].y-P[k].y)*(P[q].y-P[k].y); sort(num, num+w); w = unique(num, num+w) - num; if(w != 2) return false; return true; } int main() { while(scanf("%d", &n) != EOF) { int ans = 0; for(int i = 1; i <= n; i++) scanf("%d%d", &P[i].x, &P[i].y); for(int i = 1; i <= n; i++) for(int j = i+1; j <= n; j++) for(int k = j+1; k <= n; k++) for(int q = k+1; q <= n; q++) if(slove(i, j, k, q)) // 判断是否是正四边形 ans++; printf("%d\n", ans); } return 0; }
其实你不知道你不知道
相关文章推荐
- 深入学习C语言中的函数指针和左右法则
- 信号包络
- Spring HTTP Invoker使用介绍
- 计蒜客 难题题库 032 罗马数字
- 8月书讯:喜悦翩然而至
- 安卓安装过程
- SAP*和DDIC用户被锁分析与解决方案
- XXXX
- My debug:error C2275: “XXX”: 将此类型用作表达式非法
- atomthread 在 iar-stm8中编译错误
- 如何将动态URL静态化!
- Remove Duplicates from Sorted List II
- 计蒜客 难题题库 031 无脑博士的试管们
- 计蒜客 难题题库 030 合法分数的组合
- CSS3实现的一批hover特效
- wpf 代码设置图片路径(后台和xamll)
- 如何用PHPExcel读取超大excel文件
- 移动鼠标显示坐标及退出
- nginx安装
- 线段树之HDU1166 敌兵布阵