Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=5365
Face: (Serious spit groove, look really uncomfortable, or change it)
Run
Time limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 549 Accepted Submission (s): 245
Problem Description AFA is a girlsRunNIng. Today,sHe downloadEdAn app about runNIng. The app can record the trace of her runNIng. AFA'll start runNing in the park. There is many chairs in the park, and AFA would start his ( Her) RunNing in a chair and end in this (another) Chair. Between Chairs,she running (runs) in a line. SheShe) WantsThe (/) The Trace can ( toBe a regular triangle or a square or a regular pentagon or a regular hexagon.
Many ways can her (She) Find.
Ways is same if the set of chair that they contains is same.ways is same if chairs that and sets contains is the same.
Inputthere is multiply (multiple) cases.
In each case,there is aNInteger n (1 < = n < =) in a line.
In next n lines,there is integers xi,yi (0 < = Xi,yi < 9) in each line.
Outputoutput the number of ways.
Sample Input
40 00 11) 01 1
Sample Output
1
Sourcebestcoder Round #50 (Div.2)
Main topic:
The given 9*9 grid has some points on the line, asking how many positive triangles, squares, positive pentagon, positive hexagons can be found.
Solving:
Do, already guessed may only square is can, just too late, the puzzle but said the Earth people all know, no love ....
The amount of data is so small, how violent how to come!
Code:
#include <stdio.h> #include <iostream> #include <cstring>using namespace std;struct point{int x, y;} store[25];//whether the position is a bit labeled bool status[10][10];//determine if it is out of bool inside (int x,int y) {if (x>=0&&x<9&&y >=0&&Y<9) return True;elsereturn false;} int main () {int t,tx1,ty1,tx2,ty2,tx3,ty3,ans,xd,yd;while (~scanf ("%d", &t)) {memset (status,0,sizeof (status)); ans=0;for (int i=0;i<t;i++) {scanf ("%d%d", &store[i].x,&store[i].y);//Mark Status[store[i].x][store[i].y]= 1;} for (int i=0;i<t-1;i++) {for (int j=i+1;j<t;j++) {tx1=store[i].x; tx2=store[j].x; TY1=STORE[I].Y; TY2=STORE[J].Y; XD=TX1-TX2; Yd=ty1-ty2; All DOT enumeration for (int k=0;k<=8;k++) {for (int m=0;m<=8;m++) {//The position is a bit if (Status[k][m]) {//And not Enumeration of two points if ((k==tx1&&m==ty1) | | | (K==tx2&&m==ty2)) Continue Vertical if ((xd* (K-TX2) +yd* (m-ty2)) ==0) {//Distance equal if (((K-TX2) * (K-TX2) + (m-ty2) * (m-ty2)) = = (Xd*xd+yd*y D)) {tx3=k+xd; ty3=m+yd;//the fourth point is within the bounds, and there is an if (inside (tx3,ty3) &&status[tx3][ty3]) ans++; }}}}}}}//a square of four edges will be calculated once ans/=4;printf ("%d\n", ans);} return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Bestcoder Round #50 (Div.2) HDU 5365 Run (simple geometry)