QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#864515 | #9852. Divisions | ZhenLiu# | WA | 1ms | 3712kb | C++14 | 1.1kb | 2025-01-20 17:55:56 | 2025-01-20 17:55:56 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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