QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#581150 | #9378. Strange Binary | wykQOJ | AC ✓ | 11ms | 3820kb | C++17 | 1.2kb | 2024-09-22 10:05:08 | 2024-09-22 10:05:08 |
Judging History
answer
#include<bits/stdc++.h>
#define Max 0x7fffffff
#define LL long long
#define ULL unsigned long long//llu
#define N 1000005
//#define int long long
#define mod 1000000007
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(nullptr);
int main() {
int T; scanf("%d", &T);
while (T--) {
int n; scanf("%d", &n);
vector<int>ans(32);
int p = 0;
while (n) {
int t = n % 2;
ans[p++] = t;
n /= 2;
}
if (ans[0] == 0 && ans[1] == 0)printf("NO\n");
else {
printf("YES\n");
int fl = 0;
for (int i = 30; i >= 0; i--) {
if (ans[i + 1] == 0 && ans[i] == 0) {
ans[i + 1] = 1;
ans[i] = -1;
fl = 1;
}
else if (fl) {
if (ans[i] == 1) {
fl = 0;
}
ans[i] = -1;
}
}
for (int i = 0; i <= 31; i++) {
printf("%d ", ans[i]);
if (i % 8 == 7)printf("\n");
}
}
}
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3784kb
input:
3 0 3 5
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 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
result:
ok Accepted! (3 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3820kb
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: 11ms
memory: 3784kb
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 1 0 -1 -1 1 1 0 1 0 1 0 1 0 -1 -1 -1 1 1 0 1 0 1 -1 -1 1 -1 -1 -1 1 YES 0 1 1 -1 -1 1 1 1 1 0 1 1 0 1 1 1 0 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 1 YES -1 -1 1 -1 -1 1 1 0 1 1 0 1 0 1 0 -1 -1 -1 1 1 0 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 NO YES 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 1 -...
result:
ok Accepted! (10000 test cases)
Extra Test:
score: 0
Extra Test Passed