Skip to content

Commit

Permalink
11221 solved
Browse files Browse the repository at this point in the history
  • Loading branch information
ksaveljev committed May 16, 2011
1 parent eeb8ba9 commit d78f749
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions 11221.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main(void) {
int t;
string input;
char c;

cin >> t;
cin.ignore(100, '\n');

for (int casenum = 0; casenum < t; casenum++) {
cout << "Case #" << casenum+1 << ":" << endl;

input = "";
while (cin.peek() != '\n' && cin.peek() != -1) {
cin >> c;

if (c >= 'a' && c <= 'z')
input += c;
}
cin.ignore(100, '\n');

int sq = sqrt(input.size());

if (sq * sq != input.size()) {
cout << "No magic :(" << endl;
continue;
}

if (input != string(input.rbegin(), input.rend())) {
cout << "No magic :(" << endl;
continue;
}

string tmp = "";

for (int i = 0; i < sq; i++) {
for (int j = 0; j < sq; j++) {
tmp += input[i + j*sq];
}
}

if (tmp != input) {
cout << "No magic :(" << endl;
continue;
}

cout << sq << endl;
}

return 0;
}

0 comments on commit d78f749

Please sign in to comment.