2 条题解

  • 2
    @ 2022-4-16 12:48:24
    #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;
    }
    
    • 0
      @ 2022-4-6 21:13:38

      #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

    信息

    ID
    1233
    时间
    1000ms
    内存
    256MiB
    难度
    4
    标签
    递交数
    74
    已通过
    32
    上传者