QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#593713 | #9378. Strange Binary | wjynb666 | RE | 0ms | 4112kb | C++11 | 1.5kb | 2024-09-27 15:36:42 | 2024-09-27 15:36:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define read_fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
void solve(){
int n;
scanf("%d",&n);
if(n % 4==0){
printf("NO\n");
return ;
}
vector<int> b(32,-2);
for(int i=31;i>=0;i--){
int cur=(n>>i)&1;
if(!cur && b[i]==-2){
b[i]=1;
b[i-1]=-1;
}else if(!cur && b[i]==-1){
b[i-1]=-1;
}else if(cur && b[i]==-2) {
b[i]=1;
}
}
printf("YES\n");
for(int i=0;i<32;i++){
printf("%d ",b[i]);
if((i+1)%8==0) printf("\n");
}
}
// void solve() {
// int n;
// scanf("%d", &n);
// if (n % 4 == 0) {
// printf("NO\n");
// return;
// }
// vector<int> bit(32);
// int m = 32;
// for (int i = 0; i < m; ++i) {
// bit[i] = n % 2; // 存储 n 的 原始bit位
// n /= 2;
// }
// for (int i = 0; i < m; ++i) {
// // 贪心替换 位置为0的地方
// while (i + 1 < m && (bit[i] && !bit[i+1])) {
// bit[i+1] = 1;
// bit[i] = -1;
// ++i;
// }
// }
// printf("YES\n");
// for (int i = 0; i < m; ++i) {
// printf("%d ", bit[i]);
// if ((i + 1) % 8 == 0) {
// printf("\n");
// }
// }
// }
int main()
{
//read_fast;
int t;
cin>>t;
while(t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
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: 4112kb
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: -100
Runtime Error
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...