Files
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

40 lines
843 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int a[N];
#define x first
#define y second
typedef pair<int, int> PII;
int main() {
int cnt = 0;
a[1] = ++cnt, a[128] = ++cnt;
queue<PII> q;
q.push({1, 128});
while (q.size()) {
auto t = q.front();
q.pop();
int mid = (t.x + t.y) >> 1;
a[mid] = ++cnt, a[mid + 1] = ++cnt;
if (cnt > 32) break;
q.push({t.x, mid});
q.push({mid + 1, t.y});
}
cnt = 0;
for (int i = 1; i <= 128; i++) {
if (a[i]) {
cnt++;
printf("a[%d]=%d ", i, a[i]);
if (cnt % 5 == 0) printf("\n");
}
}
// 1肯定是12肯定是128
// 3可能是64也可能是65
// 4可能是64也可能是65
return 0;
}