Java就超时,c++就不会,看不起我Java是不是
```java
import java.util.Scanner;
public class Main {
static int n;
static int arr[][] = new int[1050][1050];
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
n = input.nextInt();
n = (int)Math.pow(2, n);
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
arr[i][j] = 1;
}
}
dfs(n, 1, 1);
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
System.out.printf("%d ", arr[i][j]);
}
System.out.println();
}
}
static void dfs(int n, int x, int y) {
if(n == 2) {
arr[x][y] = 0;
return;
}
for(int i = x; i <= x + n / 2 - 1; i++) {
for(int j = y; j <= y + n / 2 - 1; j++) {
arr[i][j] = 0;
}
}
dfs(n / 2, x, y + n / 2);
dfs(n / 2, x + n / 2, y);
dfs(n / 2, x + n / 2, y + n / 2);
}
}
c++的
```cpp
#include <iostream>
#include <cmath>
using namespace std;
const int MAX = 1050;
int n;
int arr[MAX][MAX];
void dfs(int n, int x, int y) {
if (n == 2) {
arr[x][y] = 0;
return;
}
for (int i = x; i <= x + n / 2 - 1; i++) {
for (int j = y; j <= y + n / 2 - 1; j++) {
arr[i][j] = 0;
}
}
dfs(n / 2, x, y + n / 2);
dfs(n / 2, x + n / 2, y);
dfs(n / 2, x + n / 2, y + n / 2);
}
int main() {
cin >> n;
n = pow(2, n);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
arr[i][j] = 1;
}
}
dfs(n, 1, 1);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cout << arr[i][j] << " ";
}
cout << endl;
}
return 0;
}