#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstring>
#include <stack>
#include <string>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <map>
#include <functional>
#include <set>
#include <limits.h>
#include <math.h>
#include <ctype.h>
using namespace std;
//1095
int n;
void solve(int n){
int p=0,r;
while((1<<p)<=n) p++; //等价于while(pow(2,p)<=n) p++;
p--;
if(p==0) cout<<"2(0)";
else if(p==1) cout<<"2";
else{
cout<<"2(";
solve(p);
cout<<")";
}
r=n-(1<<p);
if(r){
cout<<"+";
solve(r);
}
}
int main(){
while(cin>>n){
solve(n);
cout<<endl;
}
return 0;
}
/**************************************************************
Problem: 1095
User: cust123
Language: C++
Result: Accepted
Time:0 ms
Memory:1520 kb
****************************************************************/
题目1095:2的幂次方
最新推荐文章于 2023-12-17 16:27:03 发布