QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#593710#9378. Strange Binarywjynb666RE 0ms4076kbC++111.5kb2024-09-27 15:35:172024-09-27 15:35:18

Judging History

你现在查看的是最新测评结果

  • [2024-09-27 15:35:18]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:4076kb
  • [2024-09-27 15:35:17]
  • 提交

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;
    cin>>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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3672kb

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: 4076kb

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...

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 

result: