3 条题解
- 
  3
/***************************************** 备注: ******************************************/ #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
#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
/***************************************** 备注: ******************************************/ #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
 - 标签
 - 递交数
 - 261
 - 已通过
 - 165
 - 上传者