@[l_water](/space/show?uid=51164) 一道递归水题啊
by 周子衡 @ 2018-08-28 19:17:01
哇......我一看题目就头皮发麻....,真的不会,我宁可去刷别的啊...
by l_water @ 2018-08-28 19:18:15
你要知道友好城市这道需要dp优化的题都评了橙题。。。
by hpbl @ 2018-08-28 19:19:26
@[lhy930](/space/show?uid=60899) 。。。。。。。。
by l_water @ 2018-08-28 19:24:36
# $\color{white} \text{ YZHX是我爸爸!}$
by Cgod @ 2018-08-28 19:42:11
好吧,贴一下代码(码风奇特 请见谅)
```cpp
#include<cstdio>
using namespace std;
void out(int n)
{
if(n==1)
{
printf("2(0)");
return;
}
int t=1,ans=0;
while(n)
{
t=2;
ans=1;
while(t<=n)
{
t*=2;
ans++;
}
ans--;
t/=2;
switch(ans)
{
case 0:
printf("2(0)");
break;
case 1:
printf("2");
break;
case 2:
printf("2(2)");
break;
default:
if(n)
printf("2(");
out(ans);
putchar(')');
break;
}
n-=t;
if(n!=0)
{
putchar('+');
}
}
}
int main()
{
int n=0;
scanf("%d",&n);
out(n);
return 0;
}
```
by 周子衡 @ 2018-08-28 19:46:21
@[l_water](/space/show?uid=51164) 同
by Kai_Fu @ 2018-09-02 18:15:39
背包板子都是普及-
by SSerxhs @ 2018-10-31 00:39:36