Result: Accepted
Time: 104ms
Memory: 2300kB
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
int ax[100010];
int main (void){
int n,m;
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++){
scanf("%d",&ax[i]);
}
for(int i=0;i<n;i++){
ax[i]=(int)pow((double)ceil(pow((double)ax[i],0.5)),2);
}
if(m==1){
for(int i=0;i<n;i++){
if(i==n-1){
printf("%d\n",(int)(pow((double)ax[i],0.5)*10));
}
else printf("%d ",(int)(pow((double)ax[i],0.5)*10));
}
}
else {
for(int i=0;i<n;i++){
for(int z=0;z<m;z++){
ax[i]=ceil(pow((double)ax[i],0.5))*10;
if(ax[i]==100) break;
}
if(i==n-1){
printf("%d\n",ax[i]);
}
else {
printf("%d ",ax[i]);
}
}
}
}