QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#586083#9378. Strange Binarydaniel14311531AC ✓7ms3704kbC++20753b2024-09-24 01:29:012024-09-24 01:29:01

Judging History

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

  • [2024-09-24 01:29:01]
  • 评测
  • 测评结果:AC
  • 用时:7ms
  • 内存:3704kb
  • [2024-09-24 01:29:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100];

int main() {
	ios::sync_with_stdio(0); cin.tie(nullptr);
	int T; cin >> T;
	for(; T; --T) {
		ll x; cin >> x;
		if(x == 0) {
			cout << "NO\n"; continue;
		}
		--x;
		for(int i = 0; i <= 30; i++)
			a[i] = (x >> i) & 1;
		a[31] = 1;
		for(int i = 0; i <= 30; i++)
			a[i]--;
		if(!a[0] && !a[1]) {
			cout << "NO\n"; continue;
		}
		for(int i = 1; i < 30; i++) {
			if(a[i]) continue;
			int j; for(j = i; !a[j]; ++j);
			if(j - i <= 1) continue;
			for(int k = i - 1; k < j - 1; k++)
				a[k] = 1;
			a[j - 1] = -1;
		}
		cout << "YES\n";
		for(int i = 0; i <= 31; i++) {
			cout << a[i] << " \n"[(i + 1) % 8 == 0];
		}
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3704kb

input:

3
0
3
5

output:

NO
YES
-1 0 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 1
YES
-1 -1 0 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 1

result:

ok Accepted! (3 test cases)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

2
0
1073741823

output:

NO
YES
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 -1 -1 1

result:

ok Accepted! (2 test cases)

Test #3:

score: 0
Accepted
time: 7ms
memory: 3624kb

input:

10000
324097321
555675086
304655177
991244276
9980291
383616352
1071036550
795625380
682098056
68370721
969101726
685975156
973896269
354857775
196188000
606494155
754416123
467588829
495704303
558090120
618002000
491488050
741575237
9937018
10028830
140094825
652839595
357724903
516690123
817724271...

output:

YES
-1 -1 -1 0 -1 0 -1 -1
0 -1 0 -1 0 -1 0 -1
0 -1 -1 -1 0 -1 0 1
1 -1 -1 -1 0 -1 -1 1
YES
0 1 1 -1 -1 1 1 1
-1 1 1 -1 1 1 1 -1
1 1 1 1 -1 -1 -1 -1
0 -1 -1 -1 -1 0 -1 1
YES
-1 -1 -1 0 -1 -1 0 1
1 -1 -1 0 -1 0 -1 0
-1 -1 -1 0 -1 0 -1 -1
-1 0 -1 -1 0 -1 -1 1
NO
YES
-1 0 -1 -1 -1 -1 1 1
-1 -1 -1 0 -1 -...

result:

ok Accepted! (10000 test cases)

Extra Test:

score: 0
Extra Test Passed