提交时间:2024-01-02 13:51:52

运行 ID: 118938

#include<bits/stdc++.h> using namespace std; inline int read(){ int X=0,w=0; char ch=0; while(!isdigit(ch)){ w|=ch=='-'; ch=getchar(); } while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar(); return w?-X:X; } inline void write(int x){ if(x<0)putchar('-'),x=-x; if(x>9)write(x/10); putchar(x%10+'0'); } int a[100001]; map<int,int> mp; int main(){ int T=read(),d=read(),l=read(); while(T--){ mp.clear(); int x=read(),ans=0; a[0]=x; while(x!=0&&x!=1&&x!=-1&&x!=-5&&x!=-17){ if(x%2)x=x*3+1; else x/=2; a[++ans]=x; } while(x<=0) x+=d,a[++ans]=x; while(x!=1){ if(x%2)x=x*3+1; else x/=2; a[++ans]=x; } cout<<ans<<" "; for(int i=ans;i>=0;i--) cout<<a[i]<<" "; cout<<endl; } return 0; }