QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#864612 | #9852. Divisions | ZhenLiu | AC ✓ | 1ms | 3584kb | C++14 | 2.2kb | 2025-01-20 20:14:57 | 2025-01-20 20:14:58 |
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;
}
*/
int two[31];
int fp(int a, int n){
int ans = 1;
while(n){
if(n & 1){
ans *= a;
}
a *= a;
n >>= 1;
}
return ans;
}
int ans[366];
int main(){
int k;
int cnt = 1;
int num = 1;
cin >> k;
if(k == 1){
cout << 6 << endl;
cout << "1 1 4 5 1 4" << endl;
return 0;
}
if(k == 0){
cout << 5 << endl;
cout << "2 5 1 4 3" << endl;
return 0;
}
for(int i = 0; i <= 31; ++i){
two[i] = fp(2, i);
}
while(1){
int temp = upper_bound(two, two + 32, k) - two;
for(int i = 1; i < temp; ++i){
ans[cnt++] = num;
}
num++;
k -= two[temp - 1];
if(k <= 0){
break;
}
k++;
}
cout << cnt - 1 << endl;
for(int i = 1; i < cnt; ++i){
cout << ans[i] << " ";
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
input:
1
output:
6 1 1 4 5 1 4
result:
ok correct
Test #2:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
2
output:
1 1
result:
ok correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
0
output:
5 2 5 1 4 3
result:
ok correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
3
output:
2 1 2
result:
ok correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
4
output:
2 1 1
result:
ok correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
5
output:
3 1 1 2
result:
ok correct
Test #7:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
6
output:
4 1 1 2 3
result:
ok correct
Test #8:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
7
output:
4 1 1 2 2
result:
ok correct
Test #9:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
8
output:
3 1 1 1
result:
ok correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
9
output:
4 1 1 1 2
result:
ok correct
Test #11:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
10
output:
5 1 1 1 2 3
result:
ok correct
Test #12:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
11
output:
5 1 1 1 2 2
result:
ok correct
Test #13:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
12
output:
6 1 1 1 2 2 3
result:
ok correct
Test #14:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
13
output:
7 1 1 1 2 2 3 4
result:
ok correct
Test #15:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
14
output:
7 1 1 1 2 2 3 3
result:
ok correct
Test #16:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
15
output:
6 1 1 1 2 2 2
result:
ok correct
Test #17:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
16
output:
4 1 1 1 1
result:
ok correct
Test #18:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
24
output:
8 1 1 1 1 2 2 2 3
result:
ok correct
Test #19:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
31
output:
8 1 1 1 1 2 2 2 2
result:
ok correct
Test #20:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
32
output:
5 1 1 1 1 1
result:
ok correct
Test #21:
score: 0
Accepted
time: 1ms
memory: 3456kb
input:
63
output:
10 1 1 1 1 1 2 2 2 2 2
result:
ok correct
Test #22:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
64
output:
6 1 1 1 1 1 1
result:
ok correct
Test #23:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
127
output:
12 1 1 1 1 1 1 2 2 2 2 2 2
result:
ok correct
Test #24:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
128
output:
7 1 1 1 1 1 1 1
result:
ok correct
Test #25:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
255
output:
14 1 1 1 1 1 1 1 2 2 2 2 2 2 2
result:
ok correct
Test #26:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
256
output:
8 1 1 1 1 1 1 1 1
result:
ok correct
Test #27:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
511
output:
16 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2
result:
ok correct
Test #28:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
512
output:
9 1 1 1 1 1 1 1 1 1
result:
ok correct
Test #29:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
1023
output:
18 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2
result:
ok correct
Test #30:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
1024
output:
10 1 1 1 1 1 1 1 1 1 1
result:
ok correct
Test #31:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
16383
output:
26 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2
result:
ok correct
Test #32:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
16384
output:
14 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok correct
Test #33:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
65535
output:
30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
result:
ok correct
Test #34:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
65536
output:
16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok correct
Test #35:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
1048575
output:
38 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
result:
ok correct
Test #36:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
1048576
output:
20 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok correct
Test #37:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
8388607
output:
44 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
result:
ok correct
Test #38:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
8388608
output:
23 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok correct
Test #39:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
16777200
output:
256 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 ...
result:
ok correct
Test #40:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
16777207
output:
186 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 ...
result:
ok correct
Test #41:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
16777211
output:
124 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
result:
ok correct
Test #42:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
16777213
output:
87 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
result:
ok correct
Test #43:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
16777215
output:
46 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
result:
ok correct
Test #44:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
67108838
output:
325 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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 ...
result:
ok correct
Test #45:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
67108837
output:
324 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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 ...
result:
ok correct
Test #46:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
67108863
output:
50 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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
result:
ok correct
Test #47:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
67108864
output:
26 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:
ok correct
Test #48:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
100000000
output:
226 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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 ...
result:
ok correct
Extra Test:
score: 0
Extra Test Passed