QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#586082#9378. Strange Binarydaniel14311531Compile Error//Python3753b2024-09-24 01:28:422024-09-24 01:28:42

Judging History

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

  • [2024-09-24 01:28:42]
  • 评测
  • [2024-09-24 01:28:42]
  • 提交

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;
}

Details

  File "answer.code", line 2
    using namespace std;
          ^^^^^^^^^
SyntaxError: invalid syntax