https://www.luogu.org/problem/show?pid=2320#sub
题目描述全是图
数学思维,分治思想
假设总数为n
从n/2+1到n的数都可以用1~n的数+n/2表示出来
1~n/2的数也可以这样拆分成两份。
一路拆下去即可。
例如n=12时:
{1 2 3 4 5 6}+6={7,8,9,10,11,12}
{1,2,3}+3={4,5,6}
{1,2}+3={4,5}
{1}+2={3}
所以只需要1 2 3 6
/*by SilverN*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
const int mxn=;
int a[mxn];
int n;
int main(){
cin>>n;
int cnt=;
while(n){
a[++cnt]=(n+)/;
n/=;
}
printf("%d\n",cnt);
for(int i=cnt;i;i--)printf("%d ",a[i]);
return ;
}