提交时间:2022-10-04 11:28:53
运行 ID: 57486
#include<bits/stdc++.h> #define ll long long using namespace std; int T;ll n,d,l; stack <ll> 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; }