QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#864528 | #9852. Divisions | ZhenLiu# | WA | 1ms | 3840kb | C++14 | 1.3kb | 2025-01-20 18:12:05 | 2025-01-20 18:12:06 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans[500];
int ansbit=0,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(){
bool tag=false;
int k;
cin >> k;
if(k==1){
printf("6\n1 1 4 5 1 4\n");
return 0;
}
if(k==3){
printf("3\n1 1 2\n");
return 0;
}
int nowneed=k;
while(1){
getnum1(nowneed);
if(!tag || nowneed==1)
nowneed=num1-1;
else
nowneed=num1;
tag = true;
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: 100
Accepted
time: 0ms
memory: 3712kb
input:
1
output:
6 1 1 4 5 1 4
result:
ok correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
2
output:
1 1
result:
ok correct
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3712kb
input:
0
output:
0
result:
wrong answer empty sequence found