Solve of UVA 11716:Digital Fortress
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,d,i,j,k,L;
char z[10000],X;
scanf("%d",&a);
scanf("%c",&X);
while(a--)
{
gets(z);
b=strlen(z);
c=sqrt(b);
if((b-c*c)!=0)
{
cout<<"INVALID"<<endl;
continue;
}
else
{
for(j=0;j<c;j++)
for(i=0+j;i<b;i+=c)
cout <<z[i];
}
cout<<endl;
}
return 0;
}
No comments:
Post a Comment