QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#583869 | #9378. Strange Binary | sutu | WA | 17ms | 3704kb | C++20 | 1.0kb | 2024-09-22 23:18:38 | 2024-09-22 23:18:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
void solved() {
int n;
cin >> n;
if (n ==0) {
cout << "NO" << endl;
return;
}
int a[32];
fill(a, a + 31, -1);
a[31] = 1;
if(n==1){
cout << "YES" << endl;
for (int i = 0; i < 32; i++) {
cout << a[i] << " ";
if ((i + 1) % 8 == 0) cout << endl;
}
return ;
}
for (int i = 31; i >= 0; i--) {
if ((1 << i) & n) {
if (i > 0) {
if (a[i + 1] == 0 || a[i] == 1) {
a[i - 1] = 1;
} else {
a[i] = 0;
}
}
}
}
if (n % 2 == 0) {
a[0] -= 1;
}
for (int i = 0; i < 31; i++) {
a[i + 1] += a[i] / 2;
a[i] %= 2;
}
cout << "YES" << endl;
for (int i = 0; i < 32; i++) {
cout << a[i] << " ";
if ((i + 1) % 8 == 0) cout << endl;
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--) solved();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
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: 3704kb
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 0 -1 1
result:
ok Accepted! (2 test cases)
Test #3:
score: -100
Wrong Answer
time: 17ms
memory: 3636kb
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 0 -1 -1 0 -1 -1 1 YES 0 1 -1 0 -1 1 1 -1 0 1 -1 0 1 1 -1 0 1 1 1 -1 0 -1 -1 -1 0 -1 -1 -1 -1 0 -1 1 YES -1 -1 -1 0 -1 -1 0 1 -1 0 -1 0 -1 0 -1 0 -1 -1 -1 0 -1 0 -1 -1 -1 0 -1 -1 0 -1 -1 1 YES 0 0 -1 1 1 1 1 1 1 1 -1 0 ...
result:
wrong answer Offend Limitation 2. (test case 10000)