QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#583787 | #9378. Strange Binary | Niiu | WA | 0ms | 3548kb | C++20 | 1.1kb | 2024-09-22 22:23:32 | 2024-09-22 22:23:32 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
int pow2[32];
void init()
{
pow2[0]=1;
for(int i=1;i<=31;i++)
{
pow2[i]=pow2[i-1]*2;
}
}
void solve()
{
int x;
cin>>x;
if(x==0)
{
cout<<"NO\n";
return ;
}
vector<int>idx(32,-1);
idx[31]=1;
x--;
if(x&1)cout<<"NO\n";
else
{
for(int i=30;i>=0;i--)
{
if((x>>i)&1)
{
idx[i]=1;
}
}
int sum=0;
for(int i=0;i<=31;i++)
{
sum+=idx[i]*pow2[i];
}
//cout<<sum<<'\n';
//if(sum!=x+1)cout<<"NO\n";
//else
//{
cout<<"YES\n";
int cnt=0;
for(int i=0;i<32;i++)
{
cout<<idx[i]<<' ';
cnt++;
if(cnt%8==0)cout<<'\n';
}
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
init();
int T=1;
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: 3548kb
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)