竞赛
考级
#include<bits/stdc++.h> using namespace std; int main(){ long long n; cin >> n; if(n % 2 == 1){ cout << -1; return 0; } long long pow2[105]; for(int i = 1;i <= 24;i++){ pow2[i] = pow(2,i); } while(n != 0){ for(int i = 24;i >= 1;i--){ if(pow2[i] <= n && pow2[i+1] > n){ cout << pow2[i] << ' '; n -= pow2[i]; } } } return 0; }
DARK SPECTRE
#include<iostream> using namespace std; int main(){ int a,b=2; cin>>a; if (a%2!=0){ cout<<-1; }else{ while (a>0){ for(int i=2;i<=a;i*=2){ b*=2; } b/=2; cout<<b<<" "; a=a-b; b=2; } } }
菜
xxb
AC是最好的
胡穆尧☯️
#include <iostream> #include <vector> using namespace std; int main() { long long n; cin >> n; }
sunmimgyi
腾渊之星
#include<bits/stdc++.h> using namespace std; int main(){ int n,ans[10000],idx=0; cin>>n; if(n%2==1){ cout<<-1; return 0; } while(n>0){ ans[idx]=n%2; idx++; n/=2; } for(int i=idx-1;i>=0;i--){ if(ans[i]==1) cout<<(int)(ans[i]*pow(2,i))<<" "; }
༺ཌༀluoyongqiༀད༻
#include <bits/stdc++.h> using namespace std; long long n,ans,j = 1; int main(){ cin>>n; if(n%2==1){ ans = -1; cout<<ans; return 0; } while(pow(2,j)<10000000){ if(pow(2,j)==n){ ans = n; cout<<ans; return 0; } j++; } while(n>=2){ int tmp = 1; while(pow(2,tmp)<=n){ tmp+=1; } ans = pow(2,(tmp-1)); n-=ans; cout<<ans<<" "; } return 0; }
智造体·魁(回关)
编程之神
#include <bits/stdc++.h> using namespace std; int main(){ int a; cin>>a; int y=1; if(a%2!=0){ cout<<"-1"; } else{ while(y<a){ y=2*y; } while(a>1){ while(y>a){ y=y/2; } a=a-y; cout<<y<<" "; } } }
Code Breaker
有事找大号
༺ཌༀ元气满满ༀད༻
耐高总冠军 张文杰
共75条
提交答案之后,这里将显示提交结果~