QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#745205#9378. Strange BinaryJZYZ#Compile Error//C++141.3kb2024-11-14 08:16:122024-11-14 08:16:12

Judging History

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

  • [2024-11-14 08:16:12]
  • 评测
  • [2024-11-14 08:16:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
template <typename T>inline void read(T &x)
{
    x=0;char c=getchar();bool f=0;
    for(;c<'0'||c>'9';c=getchar())f|=(c=='-');
    for(;c>='0'&&c<='9';c=getchar())x=(x<<1)+(x<<3)+(c-'0');
    x=(f?-x:x);
}
typedef unsigned long long ull;
const int N = 2e5+7;
typedef long long LL;
LL num[N];
int main()
{
    // freopen("a.in", "r", stdin);
     //freopen("a.ans", "w", stdout);
     int t;
     read(t);
    while(t--)
    {
        LL n;
        read(n);
        if(n%4==0)
        {
            printf("NO\n");
            continue;
        }
        for(int i=0;i<=31;i++)num[i]=0;
        printf("YES\n");
        for(int i=31;i>=0;i--)
        {
            LL c=((n>>i)&1);
            if(c==1)num[i]=1;
            else
            {
                if(i==0)continue;
                int j=i-1;
                for(;j&&((n>>j)%2==0);j--);
                for(int k=i;k>=j;k--)num[k]=-1;
                num[i]=1;
                i=j;
            }
        }
        LL x=0;
        for(int i=0;i<=31;i++)x+=(1ll<<i)*num[i];
        for(int i=0,r=0;i<=31;i++,r=(r+1)%8)
        {
            printf("%lld ",num[i]);
            if(r==7)printf("\n");
        }
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:53:2: error: expected ‘}’ at end of input
   53 | }
      |  ^
answer.code:15:1: note: to match this ‘{’
   15 | {
      | ^