求调,WA on Subtack3其余点
查看原帖
求调,WA on Subtack3其余点
993941
xingchen666楼主2025/8/4 01:28
#include<bits/stdc++.h>
using namespace std;

int T,n;

int up_pow2(int x) {
	int res = 1;
	for(; res-1<x; res*=2) ;
	return res-1;
}

int vis[100010];

int main() {
	scanf("%d", &T);
	while(T--) {
		scanf("%d", &n);
		printf("%d\n", (n-1)/2+1);
		
		bool got_zero = 1;
		int x = n;
		while(x > 0) {
			int up = up_pow2(x);
			for(int i=x; up-i<i; i--) {
				printf("2 %d %d\n", up-i,i);
				if(up-i == 0) got_zero = 0;
			}
			x = up-x-1;
		}
		if(got_zero) printf("1 0\n");
	}
	
	return 0;
}

玄1关,谢谢大家

2025/8/4 01:28
加载中...