Result: Accepted
Time: 73ms
Memory: 1780kB
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
#include<string.h>
int main(void){
int a,b,c;
int i,j;
int k,t;
int w[100001];
int z[100001];
scanf("%d %d",&t,&k);
for(j=1;j<=10;j++){
w[j*j]=j*j;
for(i=1;i<=k;i++){
w[j*j]=ceil(sqrt(w[j*j]*1.0))*10;
}
}
for(i=1;i<=t;i++){
scanf("%d",&z[i]);
if(z[i]>1&&z[i]<=4)
z[i]=w[4];
else if(z[i]>4&&z[i]<=9)
z[i]=w[9];
else if(z[i]>9&&z[i]<=16)
z[i]=w[16];
else if(z[i]>16&&z[i]<=25)
z[i]=w[25];
else if(z[i]>25&&z[i]<=36)
z[i]=w[36];
else if(z[i]>36&&z[i]<=49)
z[i]=w[49];
else if(z[i]>49&&z[i]<=64)
z[i]=w[64];
else if(z[i]>64&&z[i]<=81)
z[i]=w[81];
else if(z[i]>81&&z[i]<=100)
z[i]=w[100];
else if(z[i]==1)
z[i]=w[1];
if(i==1)
printf("%d",z[i]);
else
printf(" %d",z[i]);
}
}