QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#864515#9852. DivisionsZhenLiu#WA 1ms3712kbC++141.1kb2025-01-20 17:55:562025-01-20 17:55:56

Judging History

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

  • [2025-01-20 17:55:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3712kb
  • [2025-01-20 17:55:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans[500];
int ansbit,ansnum=1;
int cnt=0;
int bitget[30],bitnum,num1;
void getnum1(int x){
    bitnum=0; num1=0;
    while(x>0){
        bitget[bitnum++]=x&1;
        if(x&1){
            ++num1;
        }
        x>>=1;
    }
    return ;
}
int main(){

    int k;
    cin >> k;
    if(k==1){
        printf("1\n1 1 4 5 1 4\n");
        return 0;
    }
    int nowneed=k;
    while(1){
        getnum1(nowneed);
        nowneed=num1-1;
        for(int i=bitnum-1;i>=0;--i){
            if(bitget[i]==1){
                if(i>=1)
                    for(int j=1;j<=i;++j)
                        ans[++ansbit]=ansnum;
                else
                    ans[++ansbit]=ansnum;
                ++ansnum;
            }
        }
        if(ansbit>365){
            printf("-1");
            return 0;
        }
        if(nowneed==0)
            break;
    }
    printf("%d\n",ansbit);
    for(int i=1;i<=ansbit;++i)
        printf("%d ",ans[i]);
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3712kb

input:

1

output:

1
1 1 4 5 1 4

result:

wrong answer wrong answer