QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#581686 | #9378. Strange Binary | huangce | AC ✓ | 19ms | 3600kb | C++17 | 1.2kb | 2024-09-22 13:53:50 | 2024-09-22 13:53:51 |
Judging History
answer
/*
* @Author: dsaDadas11
* @Date: 2024-06-27 10:33:26
* @LastEditTime: 2024-09-22 13:53:24
* @Description: go for it!
*/
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define int ll
using namespace std;
constexpr int N=1e6+7;
constexpr int M=2e3+7;
int n;
int a[37]; // 0-31
int p[37];
void pre()
{
p[0]=1;
for(int i=1;i<=32;i++)
{
p[i]=p[i-1]*2;
}
}
void solve()
{
cin>>n;
int t=n;
// if(n%4==0)
// {
// cout<<"NO"<<endl;
// return;
// }
for(int i=0;i<=31;i++) a[i]=1;
bool flag=0;
if(n%2==0) flag=1;
vector<int> v;
while(n)
{
if(n&1) v.push_back(1);
else v.push_back(0);
n>>=1;
}
while((int)v.size()!=32) v.push_back(0);
v.push_back(1);
for(int i=0;i<=31;i++)
{
a[i]=v[i+1];
}
for(int i=0;i<=31;i++)
{
if(a[i]==0) a[i]=-1;
}
if(flag) a[0]=0;
int res=0;
for(int i=0;i<=31;i++)
{
res+=a[i]*p[i];
}
if(res!=t)
{
cout<<"NO"<<endl;
return;
}
cout<<"YES"<<endl;
for(int i=0;i<=31;i++)
{
cout<<a[i]<<' ';
if((i+1)%8==0) cout<<endl;
}
}
signed main()
{
//ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
pre();
int T=1; cin>>T;
while(T--){solve();}
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
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: 3516kb
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: 0
Accepted
time: 19ms
memory: 3600kb
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 YES 0 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 NO YES 1 -1 -1 -1 -1 -1 1 1 -1...
result:
ok Accepted! (10000 test cases)
Extra Test:
score: 0
Extra Test Passed