6 条题解

  • 3
    @ 2021-11-15 21:51:58
    /*****************************************
    备注:
    ******************************************/
    #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[1000][1000];
    void f(int x , int y , int n)
    {
    	if(n == 1)
    	{
    		a[x][y] = 'X';
    		return ;
    	}
    	f(x,y,n-1);
    	f(x,y+pow(3,n-2)*2,n-1);
    	f(x+pow(3,n-2),y+pow(3,n-2),n-1);
    	f(x+pow(3,n-2)*2,y,n-1);
    	f(x+pow(3,n-2)*2,y+pow(3,n-2)*2,n-1);
    }
    int main()
    {
    	int n;
    	memset(a,' ',sizeof( a));
    	while(cin >> n && ~n)
    	{
    		f(0 , 0 , n);
    		for(int i = 0 ; i < pow(3,n-1) ; i++)
    		{
    			for(int j = 0 ; j < pow(3,n-1) ; j++)
    				printf("%c", a[i][j]);
    			puts("");
    		}
    		puts("-");
    	}
    	return 0;
    }
    
    • 0
      @ 2022-4-17 15:03:51
      #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[1000][1000];
      void f(int x , int y , int n)
      {
      	if(n == 1)
      	{
      		a[x][y] = 'X';
      		return ;
      	}
      	f(x,y,n-1);
      	f(x,y+pow(3,n-2)*2,n-1);
      	f(x+pow(3,n-2),y+pow(3,n-2),n-1);
      	f(x+pow(3,n-2)*2,y,n-1);
      	f(x+pow(3,n-2)*2,y+pow(3,n-2)*2,n-1);
      }
      int main()
      {
      	int n;
      	memset(a,' ',sizeof( a));
      	while(cin >> n && ~n)
      	{
      		f(0 , 0 , n);
      		for(int i = 0 ; i < pow(3,n-1) ; i++)
      		{
      			for(int j = 0 ; j < pow(3,n-1) ; j++)
      				printf("%c", a[i][j]);
      			puts("");
      		}
      		puts("-");
      	}
      	return 0;
      }
      
      • 0
        @ 2021-12-7 17:27:11

        笑死,根本看不懂(w

        • 0
          @ 2021-12-7 17:25:29

          我悟了!

          • 0
            @ 2021-8-10 21:48:04

            这题有人会吗

          • -1
            @ 2021-12-5 8:39:10
            /*****************************************
            备注:
            ******************************************/
            #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[1000][1000];
            void f(int x , int y , int n)
            {
            	if(n == 1)
            	{
            		a[x][y] = 'X';
            		return ;
            	}
            	f(x,y,n-1);
            	f(x,y+pow(3,n-2)*2,n-1);
            	f(x+pow(3,n-2),y+pow(3,n-2),n-1);
            	f(x+pow(3,n-2)*2,y,n-1);
            	f(x+pow(3,n-2)*2,y+pow(3,n-2)*2,n-1);
            }
            int main()
            {
            	int n;
            	memset(a,' ',sizeof( a));
            	while(cin >> n && ~n)
            	{
            		f(0 , 0 , n);
            		for(int i = 0 ; i < pow(3,n-1) ; i++)
            		{
            			for(int j = 0 ; j < pow(3,n-1) ; j++)
            				printf("%c", a[i][j]);
            			puts("");
            		}
            		puts("-");
            	}
            	return 0;
            }
            
            • 1

            信息

            ID
            29
            时间
            1000ms
            内存
            128MiB
            难度
            2
            标签
            递交数
            215
            已通过
            130
            上传者