QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#595405#9378. Strange Binarypiaoyun#WA 0ms3584kbC++14960b2024-09-28 13:38:412024-09-28 13:38:42

Judging History

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

  • [2024-09-28 13:38:42]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3584kb
  • [2024-09-28 13:38:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long

int N;
int a[34];
void prepare(){
    cin >> N;
    if(N == 0){
        cout << "NO" << "\n";
        return;
    }
    for(int i = 31; i >= 0; i--){
        if(N & (1ll << i)){
            a[i] = 1;
        }
    }
    for(int i = 31; i >= 1; i--){
        if(a[i] == 0 && a[i-1] == 0){
            a[i] = 1;
            a[i-1] = -1;
            int pnt = i - 2;
            while(pnt >= 0){
                if(a[pnt] == 1){
                    a[pnt] = -1;
                    break;
                }
                else a[pnt] = -1;
                pnt--;
            }

        }
    }
    cout << "YES" << '\n';
    for(int i = 0; i <= 31; i++){
        cout << a[i] << " ";
        if(i % 8 == 7) cout << "\n";
    }

}

signed main(){
    ios::sync_with_stdio(false);
    int T;
    cin >> T;
    while(T--){
        prepare();
    }
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3584kb

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:

wrong answer Offend Limitation 3. (test case 3)