提交时间:2022-10-04 11:51:48

运行 ID: 57525

#include<bits/stdc++.h> using namespace std; int T,n,d,l; stack <int> ans; int main(){ scanf("%d%lld%ld",&T,&d,&l); while(T--){ scanf("%lld",&n); while(n^1){ if(!n) ans.push(0),n=1; if((n^1)&&abs(n)&1) ans.push(n),n=n*3+1; while(n&&!(abs(n)&1)) ans.push(n),n/=2; if(n<=0&&min(-n,d-n)<=l) ans.push(n),n+=d; } printf("%d 1 ",ans.size()); while(!ans.empty()){ printf("%lld ",ans.top()); ans.pop(); }puts(""); } return 0; }