QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#593728 | #9378. Strange Binary | wjynb666 | WA | 0ms | 4088kb | C++11 | 1.5kb | 2024-09-27 15:42:02 | 2024-09-27 15:42:02 |
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>=1;i--){
int cur=(n>>i)&1;
if(cur==0 && b[i]==-2 ){
b[i]=1;
b[i-1]=-1;
}else if(cur==0 && 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: 0
Wrong Answer
time: 0ms
memory: 4088kb
input:
3 0 3 5
output:
NO YES -2 -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:
wrong answer Integer parameter [name=Offend Limitation 1.] equals to -2, violates the range [-1, 1] (test case 3)