Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
168887 蒋礼谦 幂次方 C++ 输出超限 57 0 MS 256 KB 824 2024-08-20 14:17:09

Tests(4/7):


#include<iostream> #include<string> using namespace std; string b[20]={"2(0)","2","2(2)","2(2+2(0))","2(2(2))","2(2(2)+2(0))","2(2(2)+2)","2(2(2)+2+2(0))","2(2(2+2(0)))","2(2(2+2(0))+2(0))","2(2(2+2(0))+2)","2(2(2+2(0))+2+2(0))","2(2(2+2(0))+2(2))","2(2(2+2(0))+2(2)+2(0))","2(2(2+2(0))+2(2)+2)","2(2(2+2(0))+2(2)+2+2(0))"}; int n,x[20],step=-1,first=2e9; int main() { cin>>n; while(n>=1) { step++; if(n%2==1) { first=min(first,step); x[step]=1; } n/=2; } for(int i=step;i>=0;i--) { if(x[i]==1) { if(i==first) { cout<<b[i]; } else { cout<<b[i]<<"+"; } } } return 0; }


测评信息: