QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#715677 | #9378. Strange Binary | Stargazer# | AC ✓ | 15ms | 3696kb | C++20 | 1.2kb | 2024-11-06 12:59:38 | 2024-11-06 12:59:39 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define fi first
#define se second
#define bg begin
#define gc getchar
inline int read(){
char ch=gc();
int res=0;bool f=1;
while(!isdigit(ch))f^=ch=='-',ch=gc();
while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
return f?res:-res;
}
inline ll readll(){
char ch=gc();
ll res=0;bool f=1;
while(!isdigit(ch))f^=ch=='-',ch=gc();
while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
return f?res:-res;
}
template<typename tp>inline void chemx(tp &a,tp b){(a<b)?(a=b):0;}
template<typename tp>inline void chemn(tp &a,tp b){(a>b)?(a=b):0;}
cs int N=35;
int a[N];
void solve(){
int n=read();
for(int i=0;i<32;i++)a[i]=n&1,n/=2;
int lst=32;
for(int i=31;i>=0;i--){
if(a[i]==1){
if(lst-2>i){
a[lst-1]=1;
for(int j=lst-2;j>=i;j--)a[j]=-1;
}
lst=i;
}
}
for(int i=0;i<31;i++)if(a[i]==0&&a[i+1]==0){
puts("NO");return;
}
puts("YES");
for(int i=0;i<32;i++){
cout<<a[i]<<" ";
if(i%8==7)puts("");
}
}
int main(){
#ifdef Stargazer
freopen("1.in","r",stdin);
#endif
int T=read();
while(T--)solve();
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
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 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
result:
ok Accepted! (3 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3636kb
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: 15ms
memory: 3696kb
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 0 -1 -1 1 1 0 1 0 1 0 1 0 -1 -1 -1 1 1 0 1 0 1 -1 -1 1 -1 -1 -1 1 YES 0 1 1 -1 -1 1 1 1 1 0 1 1 0 1 1 1 0 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 1 YES -1 -1 1 -1 -1 1 1 0 1 1 0 1 0 1 0 -1 -1 -1 1 1 0 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 NO YES 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 1 -...
result:
ok Accepted! (10000 test cases)
Extra Test:
score: 0
Extra Test Passed