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 |
又是个大水题#include <iostream> #include <string> using namespace std; int N; struct pt{ int x,y; }; int distSq(pt p1, pt p2){ return (p2.x-p1.x)*(p2.x-p1.x) + (p2.y-p1.y)*(p2.y-p1.y) - (p2.x-p1.x)*(p2.y-p1.y); } int main() { while(cin >> N){ if(N == 0) return 0; string s; cin >> s; pt points[26][3]; int pointNum[26] = {0}; int offset = 0; for(int i = 0; i < N; i++){ for(int j = 0; j <= i; j++){ char c = s[offset]; points[c-'a'][pointNum[c-'a']].x = i, points[c-'a'][pointNum[c-'a']].y = j; offset++; pointNum[c-'a']++; } } int cnt = 0; for(int i = 0; i < 26; i++){ if(pointNum[i] != 3) continue; int d1 = distSq(points[i][0], points[i][1]); int d2 = distSq(points[i][0], points[i][2]); int d3 = distSq(points[i][1], points[i][2]); if(d1 == d2 && d2 == d3){ cnt++; cout << (char)(i+'a'); } } if(cnt == 0) cout << "LOOOOOOOOSER!"; 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