QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#580373#9378. Strange BinaryyywxdgyCompile Error//C++141019b2024-09-21 21:32:512024-09-21 21:32:52

Judging History

你现在查看的是最新测评结果

  • [2024-09-21 21:32:52]
  • 评测
  • [2024-09-21 21:32:51]
  • 提交

answer

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int T, n;
int a[40], cnt = 0;
void Apply(int x, int l, int r) {
	a[l] = x; for (int i = l + 1; i <= r; ++i) a[i] = -x;
}
void Work(int nn) {
	n = nn;
	int y = n;
	cnt = 0, memset(a, 0, sizeof(a));
	while (y) a[++cnt] = y % 2, y >>= 1;
	cnt = 32;
	reverse(a + 1, a + cnt + 1);
	int conti = 0, l = 1, r;
	for (int i = 1; i <= cnt; ++i) {
		if (a[i] == 0) ++conti, (conti == 1 ? l = r = i : r = i);
		if (a[i] != 0 && conti > 1) Apply(a[i], l, r), a[i] = -a[i], conti = 0;
		if (a[i] != 0) l = r = i + 1;
	}
	if (conti > 1) return puts("NO"), void(); 
	puts("YES");
	reverse(a + 1, a + cnt + 1);
	int sum = 0;
	for (int i = 1; i <= cnt; ++i) 
		printf("%d%c", a[i], i%8!=0?' ':'\n');
	// cout << sum << endl;
	// if (sum != n) { puts("114514"); exit(0);}
}
int main() {
	cin >> T; while (T --) Work();
	// for (int i = 1; i <= 1000; ++i) Work(i);
	// Work(0);
	return 0;
}
/*

11
0
1
2
3
4
5
6
7
8
9
10
*/

Details

answer.code: In function ‘int main()’:
answer.code:32:36: error: too few arguments to function ‘void Work(int)’
   32 |         cin >> T; while (T --) Work();
      |                                ~~~~^~
answer.code:9:6: note: declared here
    9 | void Work(int nn) {
      |      ^~~~