想不出来:参考题解:
https://www.luogu.org/blog/user50514/solution-p2320
https://www.luogu.org/blog/user26625/solution-p2320
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include<iostream> #include<algorithm> #define ll long long using namespace std; ll ans,n,z[70]; int main(){ cin>>n; while(n){ z[++ans]=(n+1)/2; n/=2; } sort(z+1,z+ans+1); cout<<ans<<endl; for(int i=1;i<=ans;i++)cout<<z[i]<<" "; } |