#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
int main(){
int t, limit, flag, i;
string ans, code;
cin >> t;
getchar();
while(t--){
getline(cin, code);
int l = code.size();limit = sqrt(l);flag = 0;
for(i = 1; i <= limit; i++)
if(i*i == l){flag = 1;break;}
if(flag == 1){
for(int j = 0; j < i; j++)
for(int k = j; k < l; k += i)
ans.push_back(code[k]);
cout << ans << endl;
}
else puts("INVALID");ans.clear();
}
return 0;
}
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
int main(){
int t, limit, flag, i;
string ans, code;
cin >> t;
getchar();
while(t--){
getline(cin, code);
int l = code.size();limit = sqrt(l);flag = 0;
for(i = 1; i <= limit; i++)
if(i*i == l){flag = 1;break;}
if(flag == 1){
for(int j = 0; j < i; j++)
for(int k = j; k < l; k += i)
ans.push_back(code[k]);
cout << ans << endl;
}
else puts("INVALID");ans.clear();
}
return 0;
}
No comments:
Post a Comment