Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
127941 | 梁思宸 | 循环比赛 | C++ | 通过 | 100 | 0 MS | 288 KB | 650 | 2024-01-25 11:06:13 |
#include <bits/stdc++.h> using namespace std; int a[105][105], m; void f (int x, int y, int len, int z){ int t = pow(2, len); if (t == 1){ a[x][y] = z; return; } f(x, y, len - 1, z); f(x + t / 2, y + t / 2, len - 1, z); f(x + t / 2, y, len - 1, z + t / 2); f(x, y + t / 2, len - 1, z + t / 2); } int main (){ scanf("%d", &m); f(1, 1, m, 1); for (int i = 1; i <= pow(2, m); i++){ for (int j = 1; j <= pow(2, m); j++){ if (j == pow(2, m)) printf("%d", a[i][j]); else printf("%-4d", a[i][j]); } printf("\n"); } return 0; }