5 条题解
-
2
#include <queue> #include <math.h> #include <stack> #include <stdio.h> #include <iostream> #include <vector> #include <iomanip> #include <string.h> #include <algorithm> using namespace std; #define LL long long const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; char a[1030][2050]; void f(int n,int x,int y) { if(n==1) { a[x][y+1]=a[x+1][y]='/'; a[x][y+2]=a[x+1][y+3]='\\'; a[x+1][y+1]=a[x+1][y+2]='_'; return ; } f(n-1,x,y+pow(2,n-1)); f(n-1,x+pow(2,n-1),y); f(n-1,x+pow(2,n-1),y+pow(2,n)); } int main() { memset(a,' ',sizeof a); int n; cin >> n; f(n,0,0); for(int i=0;i<pow(2,n);i++) { for(int j=0;j<pow(2,n+1);j++) cout<<a[i][j]; cout << endl; } return 0; } -
1
#include<bits/stdc++.h> using namespace std;
char a[2000][3000];
void f(int n,int x,int y)
{
if(n==1)
{
a[x][y]='/';
a[x-1][y+1]='/';
a[x][y+1]='';
a[x][y+2]='';
a[x-1][y+2]='\';
a[x][y+3]='\';
return;
}
f(n-1,x,y);
f(n-1,x-pow(2,n-1),y+pow(2,n-1));
f(n-1,x,y+pow(2,n)); }
int main()
{
int n;
cin>>n;
memset(a,' ',sizeof(a));
f(n,pow(2,n),1);
for(int i=1;i<=pow(2,n);i++)
{
for(int j=1;j<=pow(2,n+1);j++) {
cout<<a[i][j];
}
cout<<endl;
}
return 0;
} -
1
#include <bits/stdc++.h>//万能头文件
using namespace std;
char a[2000][3000];
void f(int n,int x,int y){
if(n==1){ a[x][y]='/';//找起点 a[x-1][y+1]='/'; a[x][y+1]='_'; a[x][y+2]='_'; a[x-1][y+2]='\\'; a[x][y+3]='\\'; return; } f(n-1,x,y); f(n-1,x-pow(2,n-1),y+pow(2,n-1)); f(n-1,x,y+pow(2,n));}
int main(){
int n; cin>>n; memset(a,' ',sizeof(a));//初始化 f(n,pow(2,n),1); for(int i=1;i<=pow(2,n);i++){ for(int j=1;j<=pow(2,n+1);j++){ cout<<a[i][j]; } cout<<endl; }return 0;
}
-
0
#include<bits/stdc++.h>
char s[2000][2000];
int main()
{
int n; scanf("%d",&n); memset(s,' ',sizeof(s)); s[1][1]=s[1][4]=' '; s[1][2]=s[2][1]='/'; s[2][2]=s[2][3]='_'; s[1][3]=s[2][4]='\\'; int h=2,w=4; for(int i=1;i<n;i++) { for(int x=1;x<=h;x++) { for(int y=1;y<=w;y++) { s[x+h][y]=s[x+h][y+w]=s[x][y]; s[x][y]=' '; } } for(int x=1;x<=h;x++) { for(int y=1;y<=w;y++) { s[x][y+w/2]=s[x+h][y]; } } h*=2;w*=2; } for(int i=1;i<=h;i++) { for(int j=1;j<=w;j++) { printf("%c",s[i][j]); } printf("\n"); } return 0;} //90分代码
-
-1
```/*#include <algorithm> #include <stdio.h> #include <bitset> #include <string.h> #include <math.h> #include <cctype> #include <cerrno> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <exception> #include <fstream> #include <functional> #include <limits> #include <list> #include <map> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <utility> #include <vector> #include <cwchar> #include <cwctype> #include <complex.h> #include <fenv.h> #include <inttypes.h> #include <stdbool.h> #include <stdint.h> #include <tgmath.h> #include <windows.h> #include <stdio.h> #include <conio.h> #include <time.h> #include <unistd.h>*/ #include <bits/stdc++.h> using namespace std; //放心写吧… char a[2000][3000]; void f(int n,int x,int y){ if(n==1){ a[x][y]='/'; a[x-1][y+1]='/'; a[x][y+1]='_'; a[x][y+2]='_'; a[x-1][y+2]='\\'; a[x][y+3]='\\'; return; } f(n-1,x,y); f(n-1,x-pow(2,n-1),y+pow(2,n-1)); f(n-1,x,y+pow(2,n)); } int main(){ int n; cin>>n; memset(a,' ',sizeof(a)); f(n,pow(2,n),1); for(int i=1;i<=pow(2,n);i++){ for(int j=1;j<=pow(2,n+1);j++)cout<<a[i][j]; cout<<"\n"; } return 0; }
- 1
信息
- ID
- 1233
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 4
- 标签
- 递交数
- 173
- 已通过
- 76
- 上传者