Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
写的不好,但Accept了#include<iostream> using namespace std; const int Max=100; int Can_fasten(int m,int n,int S,int posion[Max][Max]) { int i; int j; int dis0=0,dis1; if (posion[m][n]==1) return -1; for(i=1; i<S; i++) for(j=1; j<S; j++) { if (posion[i][j]==1) { dis1=(m-i)*(m-i)+(n-j)*(n-j); if (dis1 > dis0) { dis0 = dis1; } } } if ((dis0 <= m*m)&&(dis0 <= n*n) &&(dis0 <= (S-m)*(S-m))&& (dis0 > 0)&&(dis0 <= (S-n)*(S-n))) { return 1; } return 0; } int main() { int i; int j; int posion[Max][Max]; int S; int H; int N; int X; int Y; int f; int flag; cin>>N; while (N) { cin>>S>>H; for (i=0; i<=S; i++) for (j=0; j<=S; j++) { posion[i][j]=0; } for (i=0; i<H; i++) { cin>>X>>Y; posion[X][Y]=1; } f=0; for (i=0; i<=S; i++) { if (f==1) { break; } for (j=0; j<=S; j++) { flag=Can_fasten(i, j, S, posion); if (flag==1) { cout<<i<<" "<<j<<endl; f=1; } if (f==1) { break; } } } if (f==0) { cout<<"poodle"<<endl; } N--; } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator