题解
任何数一定可以被二进制表示下最低位的一及以下的二次方数整除
code
#include<bits/stdc++.h>
#define ll long long
#define lowbit(x) ((x)&(-x))
using namespace std;
void solve()
{
int n;
cin>>n;
int m=log2(n);
int n1=1<<m;
vector<int> ans;
ans.push_back(n);
while(n1!=n)
{
n-=lowbit(n);
ans.push_back(n);
}
while(n!=1)
{
n>>=1;
ans.push_back(n);
}
cout<<ans.size()<<'\n';
for(auto it:ans) cout<<it<<' ';
cout<<'\n';
}
int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t=1;
cin>>t;
while(t--) solve();
return 0;
}
标签:Divisor,Chain,int,back,while,ans,push
From: https://www.cnblogs.com/pure4knowledge/p/18317588