题目:
​​​题目链接​

题解:
纯模拟

#include <bits/stdc++.h>
using namespace std;
int ans[1005];
int b[1005];
int main()
{
int n;
cin>>n;
char a;
cin>>a;
int r=1;
int f=r;
int l=1;
int re=l;
for(int i=1;i<=n;i++)
{
if(i==r)
{
f=r;
re=l;
ans[i]=i;
b[i]=l;
l+=2;
r+=2*l;
}
else if(i<r) ans[i]=f,b[i]=re;
// cout<<l<<" "<<r<<" "<<ans[i]<<" "<<b[i]<<endl;
}
for(int i=b[n];i>=1;i-=2)
{
for(int j=0;j<(b[n]-i)/2;j++) cout<<" ";
for(int j=1;j<=i;j++)
{
cout<<a;
}
cout<<endl;
}
for(int i=1+2;i<=b[n];i+=2)
{
for(int j=0;j<(b[n]-i)/2;j++) cout<<" ";
for(int j=1;j<=i;j++)
{
cout<<a;
}
cout<<endl;
}
cout<<n-ans[n]<<endl;
return 0;
}