| ||||||||||
| 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 <string>
#include <set>
using namespace std;
int main()
{
string str;
int i,j = 0;
set<string> s;
set<string>::iterator iter;
while(cin >> str && str.compare("*") != 0) {
int D = 0,length = str.length();
int maxD = length - 2;//最长子串长度
string sub = "";
while(D <= maxD) {
for(i = 0;i < length - 1 - D;i++) {//子串个数
for(j = i;j <= length - 1;j += D + 1) {//
sub += str.at(j);
if(sub.length() == 2)
break;
}
if(s.find(sub) != s.end())
break;
else
s.insert(sub);
sub = "";
}
if(i != length - 1 - D) {
cout << str << " is NOT surprising.\n";
break;
}
D++;
s.clear();
}
if(D == maxD + 1)
cout << str << " is surprising.\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