Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
173574 | C班-张腾午 | 幂次方 | C++ | 无测评数据 | 0 | 0 MS | 0 KB | 782 | 2024-08-20 21:38:29 |
#include<bits/stdc++.h> using namespace std; void bldstr(int n) { if(n==1) { cout<<"2(0)"; return; } if(n==2) { cout<<"2"; return; } int x=1,y=0; while(x<=n) { x*=2; y++; } y-=1; if(x/2==n) { cout<<"2("; bldstr(y); cout<<")"; } else { if(x==4) { cout<<"2+"; bldstr(n-x/2); } else { cout<<"2("; bldstr(y); cout<<")+"; bldstr(n-x/2); } } } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin>>n; bldstr(n); return 0; }