QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#584246 | #9378. Strange Binary | jjjjjxs | AC ✓ | 11ms | 3712kb | C++14 | 918b | 2024-09-23 10:50:01 | 2024-09-23 10:50:04 |
Judging History
answer
#include <bits/stdc++.h>
//#define int long long
#define INF 0x3f3f3f3f
#define fr first
#define se second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
int n;
int a[32];
void print()
{
cout<<"YES"<<endl;
for(int i=0;i<32;i++)
{
cout<<a[i]<<' ';
if((i+1)%8==0) cout<<endl;
}
}
void solve()
{
cin>>n;
for(int i=0;i<32;i++)
{
a[i]=(n>>i&1);
}
if(n%4==0)//开头连续两位均为0
{
cout<<"NO"<<endl;
return;
}
int lst ;
if(a[1]==1) lst = 1;
else if(a[0]==1) lst = 0;
for(int i=lst+1;i<32;i++)
{
if(a[i]==1)
{
for(int j=lst;j<i-1;j++)
{
a[j]=-1;
}
a[i-1]=1;
lst=i;
}
}
for(int i=lst;i<31;i++)
{
a[i]=-1;
}
a[31]=1;
print();
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int T=1; cin>>T;
while(T--) solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
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: 3612kb
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: 11ms
memory: 3712kb
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