mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-07-08 02:13:51 +08:00
Add FZOI Codes
This commit is contained in:
21
FZOI/「CSP-J2020」优秀的拆分.cpp
Normal file
21
FZOI/「CSP-J2020」优秀的拆分.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int n, a[30], j, k;
|
||||
int main(){
|
||||
cin >> n;
|
||||
if(n % 2 == 1) cout << -1;
|
||||
else{
|
||||
for(int i = n; i != 0; i /= 2){
|
||||
j ++ ;
|
||||
a[j] = i % 2;
|
||||
}
|
||||
k = j - 1;
|
||||
for(int i = j; i >= 1; i -- ){
|
||||
long long s = pow(2, k);
|
||||
if(a[i] != 0) cout << s << " " ;
|
||||
k -- ;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user