Result: Accepted
Time: 52ms
Memory: 10104kB
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const int maxn=10100;
typedef long long ll;
int a[maxn];
ll b[105][maxn];
int limit[maxn];
int main(){
int n,k;
memset(limit,-1,sizeof(limit));
for(int i=1;i<=100;i++){
b[i][0]=i;
for(int j=1;j<=100000;j++){
if(limit[i]!=-1)
break;
b[i][j]=10*ceil(sqrt((double)b[i][j-1]));
if(b[i][j]==100){
limit[i]=j;
}
}
}
scanf("%d %d",&n,&k);
for(int i=0;i<n;i++){
int m;
scanf("%d",&m);
if(k>=limit[m])
printf("%lld",b[m][limit[m]]);
else
printf("%lld",b[m][k]);
if(i!=n-1)
printf(" ");
}
return 0;
}