题解 CF36B 【Fractal】
我们可以直接开始在最后的画中填,而不是由原图慢慢画出结果
似乎也没什么太大区别?
这道题还有一个坑!!!!!
错了好几遍才发现要:::
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
上代码
#include <bits/stdc++.h>
using namespace std;
char c[305][305],ans[305][305];//定义范围
int n,m;
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);//别忘了!!!
cin>>n>>m;//输入小画范围
for(int i=0;i<n;++i)
for(int j=0;j<n;++j)
cin>>c[i][j];//输入小的画
int s=pow(n,m);//先求出最后大小
for(int i=0;i<s;++i)
{
for(int j=0;j<s;++j)//循环整个大的画
{
int x=i;
int y=j;//记录一下ij
int cnt=0;//判断用的
for(int k=0;k<m;++k)//小的范围
{
if (c[x%n][y%n]=='*')//小的中找
{
cnt=1;//是
break;//返回
}
x/=n;
y/=n;//进行减小
}
cout<<((cnt)?'*':'.');//通过cnt的值判断是哪个
}
cout<<endl;
}
}