QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#580322 | #9378. Strange Binary | yee7even | AC ✓ | 12ms | 3604kb | C++23 | 987b | 2024-09-21 21:06:32 | 2024-09-21 21:06:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
// using i128 = __int128;
const int inf = 0x3f3f3f3f;
const i64 Linf = 0x3f3f3f3f3f3f3f3f;
void solve() {
int n;
cin >> n;
if (n == 0 || n % 4 == 0) {
cout << "NO\n";
return;
}
vector<int> bin(32, 0);
for (i64 i = (1LL << 32) - 1 - n, j = 0; i; i >>= 1, ++j) {
if (i % 2 == 1) {
bin[j] = 1;
}
}
vector<int> a(32, 1);
for (int i = 1; i < 32; ++i) {
if (bin[i] == 1) {
a[i - 1] = -1;
}
}
if (n % 2 == 0) {
a[0] = 0;
}
cout << "YES\n";
for (int i = 0; i < 32; ++i) {
cout << a[i] << " \n"[(i + 1) % 8 == 0];
}
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr), std::cout.tie(nullptr);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3544kb
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 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! (3 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3592kb
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: 12ms
memory: 3604kb
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 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 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 1 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 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