题解
2023-07-26 09:35:34
发布于:河北
32阅读
0回复
0点赞
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
int t; scanf("%d", &t);
for (int i=1; i<=t; i++) {
int n; scanf("%d", &n);
int c = n;
int *a = new intn+1;
Loop:
if (c <= 3) goto END;
for (int j = 1, cnt = 0; j <= n; j++) {
if (a[j] == 0) {
cnt ++ ;
if (cnt == 2) {
cnt = 0;
a[j] = 1;
c--;
}
}
}
if (c<=3) goto END;
for (int j = 1, cnt = 0; j <= n; j++) {
if (a[j] == 0) {
cnt ++ ;
if (cnt == 3) {
cnt = 0;
a[j] = 1;
c--;
}
}
}
if (c>3) goto Loop;
END:
bool first = true;
for (int j=1; j<=n; j++) {
if (!a[j] && first) { printf("%d", j); first = !first; }
else if (!a[j]) printf(" %d", j);
}
putchar('\n');
delete []a;
}
return 0;
}
全部评论 1
s13
2023-08-16 来自 河北
0
有帮助,赞一个