社区讨论
哪错了???
P1010[NOIP 1998 普及组] 幂次方参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mie9ohjs
- 此快照首次捕获于
- 2025/11/25 15:41 3 个月前
- 此快照最后确认于
- 2025/11/25 16:47 3 个月前
CPP
#include<bits/stdc++.h>
using namespace std;
void a(int n){
bool isntfirst=0;
int m=(int)(log2(n));
while(n!=0){
if(isntfirst)cout<<"+";
if(m==1)cout<<"2";
else if(m==0)cout<<"2(0)";
else{
cout<<"2(";
a(m);
cout<<")";
}
n-=pow(2,m);
isntfirst=1;
}
}
int main(){
int k;
cin>>k;
a(k);
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...