FC模拟-5031. 矩阵扩张
作者:
小花猪
,
2023-06-22 22:22:47
,
所有人可见
,
阅读 141
5031. 矩阵扩张
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int n, k;
char p[500][500], ans[500][500], t[500][500];
int main() {
cin>>n>>k;
for(int i=0; i<n; i++)
for(int j=0; j<n; j++)
cin>>p[i][j];
int size = 1;
ans[0][0] = '.';
while(k --){
for(int i=0; i<size; i++){
for(int j=0; j<size; j++){
for(int x=0 ; x<n; x++){
for(int y=0 ; y<n; y++){
char c = '*';
if(ans[i][j] == '.') c = p[x][y];
t[i*n+x][j*n+y] = c;
}
}
}
}
memcpy(ans, t, sizeof ans);
size *= n;
}
for(int i=0; i<size; i++){
for(int j=0; j<size; j++){
cout<<ans[i][j];
}
cout<<endl;
}
return 0;
}