5 条题解

  • 4
    @ 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
      @ 2026-7-19 11:23:02
      
      ```#include <iostream>
      #include <cmath>
      #include <string.h>
      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("-");
      	}
      }
      • 0
        @ 2026-7-19 11:21:28

        #include #include #include <string.h> 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("-"); } }

        • 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;
          }
          
          • -2
            @ 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
            标签
            递交数
            316
            已通过
            195
            上传者