关于用栈这件事

P7071 [CSP-J2020] 优秀的拆分

so?
by BugGod @ 2023-10-15 12:05:48



by linzongte @ 2023-10-15 12:12:56


名字危
by IOI_AK_TLR @ 2023-10-15 12:15:26


头像有品 (赞赏
by jasonshen_ @ 2023-10-15 12:19:51


what do you want to express by this article
by 初星逝者 @ 2023-10-15 12:27:39


不只是你 ```cpp #include<bits/stdc++.h> #define int long long using namespace std; int n,cnt,f=2; stack <int> s; signed main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin>>n; if(n%2==1){ cout<<-1; return 0; }else{ cnt=n/2; while(cnt>0){ if(cnt%2==1){ s.push(f),cnt--; } f*=2,cnt/=2; } } while(!s.empty()){ cout<<s.top()<<" "; s.pop(); } return 0; }
by IAKIOI__ @ 2023-10-21 18:08:16


|