QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#586791#9378. Strange Binaryeastcloud#WA 0ms3676kbC++201.2kb2024-09-24 15:35:342024-09-24 15:35:34

Judging History

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

  • [2024-09-24 15:35:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3676kb
  • [2024-09-24 15:35:34]
  • 提交

answer


#include<bits/stdc++.h>

#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define cpy(x,y,s) memcpy(x,y,sizeof(x[0])*(s))
#define mset(x,v,s) memset(x,v,sizeof(x[0])*(s))
#define all(x) begin(x),end(x)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ary array

using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9')f=(ch=='-'?-1:f),ch=getchar();
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return x*f;
}
void write(int x){
    if(x<0)x=-x,putchar('-');
    if(x/10)write(x/10);
    putchar(x%10+'0');
}

void solve(){
    int x=read();
    if(x%4==0){printf("NO\n");return;}
    printf("YES\n");
    int cnt=0,now=0;
    for(int i=31;i>=0;i--){
        if(i==0 && !(x&1)){write(0);putchar('\n');break;}
        int val=(1<<i);
        if(abs(now+val-x)<=abs(now-val-x))now+=val,write(1);
        else now-=val,write(-1);
        cnt++;
        if(cnt==8)cnt=0,putchar('\n');
        else putchar(' ');
    }
}

int main(){
    #ifdef EAST_CLOUD
    freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    #endif

    int T=read();while(T--)solve();

    return 0;
}

详细

Test #1:

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

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)