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 |
Re:谁能告诉我这代码为啥WA,自己感觉一点问题也没啊。。In Reply To:谁能告诉我这代码为啥WA,自己感觉一点问题也没啊。。 Posted by:taozifish at 2011-06-16 11:59:47 看看我的,同是天涯沦落人。。。你现在A了没? #include <cstdio> #include <iostream> #include <cmath> #include <vector> #include <algorithm> #include <cstring> using namespace std; #define M 400 #define eps 1e-8 struct Point { double x; double y; }point[M]; char str[M]; void build() { int t = 20; int cot = 0; for(int i=1;i<=20;i++) { int h = i-1; for(int j=1;j<=i;j++) { point[cot].x = ((double)h*sqrt(3)); point[cot].y = ((double)2*(j-1)-h); cot++; } } } double getDis(Point a,Point b) { return (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y); } int main() { int n; build(); while(scanf("%d",&n) && n) { vector<char> ans; scanf("%s",str); for(int i=0;str[i];i++) { int t1 = i,t2,t3; for(int j=i+1;str[j];j++) if(str[j] == str[i]) { t2 = j; for( int k=j+1;str[k];k++) if(str[k] == str[i]) { t3 = k; // cout<<str[t1]<<t1<<" "<<t2<<" "<<t3<<endl; // cout<<point[t1].x<<" "<<point[t1].y<<endl; // cout<<point[t2].x<<" "<<point[t2].y<<endl; // cout<<point[t3].x<<" "<<point[t3].y<<endl; if(fabs(getDis(point[t1],point[t2])-getDis(point[t2],point[t3]))<eps && fabs(getDis(point[t1],point[t3])-getDis(point[t1],point[t2])<eps)) ans.push_back(str[t1]); } } } if(ans.size() == 0) printf("LOOOOOOOOSER!\n"); else { bool mark[27]; memset(mark,0,sizeof(mark)); sort(ans.begin(),ans.begin()+ans.size()); for(int i=0;i<ans.size();i++) { if(!mark[ans[i]-'a'] ) { printf("%c",ans[i]); mark[ans[i]-'a'] = true; } } cout<<endl; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator