7 条题解

  • 0
    @ 2025-3-30 10:36:56

    /***************************************** 备注: ******************************************/ #include #include <math.h> #include #include <stdio.h> #include #include #include #include <string.h> #include 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; }

    信息

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