| ||||||||||
| 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 | |||||||||
谁能告诉我这代码为啥WA,自己感觉一点问题也没啊。。#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const double T=sqrt(3.0);
const double EP=1e-8;
struct Point{double x, y;};
struct Pointset{Point p[100]; int sum;}s[27];
int n, flag[27];
char c[100];
void init(){
int i, j, k=0, t;
for(i=0; i<26; i++)
s[i].sum=0;
memset(flag, 0, sizeof(flag));
for(i=1; i<=n; i++)
for(j=1; j<=i; j++){
t=c[k++]-'a';
s[t].p[s[t].sum].x=2*j-i-1.0;
s[t].p[s[t].sum].y=i*T;
s[t].sum++;
}
}
double dist(Point p1, Point p2){
return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y);
}
int main(){
//freopen("1.txt", "r", stdin);
int f, i, j, l, k, t;
while(scanf("%d", &n)&&n){
f=0;
scanf("%s", c);
init();
for(i=0; i<26; i++){
t=s[i].sum;
for(j=0; j<t-2; j++){if(flag[i])break;
for(k=j+1; k<t-1; k++){if(flag[i])break;
for(l=k+1; l<t; l++){
if(fabs(dist(s[i].p[j],s[i].p[k])-dist(s[i].p[j],s[i].p[l]))<EP&&
fabs(dist(s[i].p[j],s[i].p[k])-dist(s[i].p[k],s[i].p[l]))<EP){
flag[i]=1;f=1;break;
}}
}
}
}
if(!f){printf("LOOOOOOOOSER!\n");break;}
for(i=0; i<26; i++)
if(flag[i])
printf("%c", 'a'+i);
printf("\n");
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator