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 |
2个for循环搞定,附拙劣代码#define N 700 #define M 80 using namespace std; int d[N]; char s[M]; int change(char c1, char c2) { return (c1-'A')*26 + (c2-'A'); } bool judge() { int l = strlen(s); for(int i=1; i<l-1; ++i) { memset(d, 0, sizeof(d)); for(int j=0; i+j<l; ++j) { int k = change(s[j], s[j+i]); if(d[k] != 0) return false; else d[k] = 1; } } return true; } int main() { while(scanf("%s", s)!=EOF && s[0]!='*') printf("%s is %s.\n", s, judge()?"surprising":"NOT surprising"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator