Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
108624 林扬泉 全排列问题 C++ 解答错误 0 0 MS 264 KB 530 2023-11-04 09:07:53

Tests(0/5):


#include<bits/stdc++.h> using namespace std; int a[10001]={1},n,total; int print(int t){ cout<<n<<"="; for(int i=1;i<t;i++){ cout<<a[i]<<"+"; } cout<<a[t]<<endl; total++; } int dfs(int cur,int t){ int i; for(i=a[t-1];i<=cur;i++){ if(i<n){ a[t]=i; cur-=i; if(cur==0){ print(t); } else{ dfs(cur,t+1); } cur+=i; } } } int main(){ //freopen("split.in","r",stdin); //freopen("split.out","w",stdout); cin>>n; dfs(n,1); cout<<"total="<<total; return 0; }


测评信息:

输入

2

输出

2=1+1
total=1

答案

12
21
2

系统信息

exit code: 0, checker exit code: 0

输入

5

输出

5=1+1+1+1+1
5=1+1+1+2
5=1+1+3
5=1+2+2
5=1+4
5=2+3
total=6

答案

12345
12354
12435
12453
12534
12543
13245
13254
13425
13452
13524
13542
14235
14253
14325
14352
14523
14532
15234
15243
15324
15342
15423
15432
21345
21354
21435
21453
21534
21543
23145
23154
23415
2...

系统信息

exit code: 0, checker exit code: 0

输入

1

输出

total=0

答案

1
1

系统信息

exit code: 0, checker exit code: 0

输入

6

输出

6=1+1+1+1+1+1
6=1+1+1+1+2
6=1+1+1+3
6=1+1+2+2
6=1+1+4
6=1+2+3
6=1+5
6=2+2+2
6=2+4
6=3+3
total=10

答案

123456
123465
123546
123564
123645
123654
124356
124365
124536
124563
124635
124653
125346
125364
125436
125463
125634
125643
126345
126354
126435
126453
126534
126543
132456
132465
132546
132564
132...

系统信息

exit code: 0, checker exit code: 0

输入

8

输出

8=1+1+1+1+1+1+1+1
8=1+1+1+1+1+1+2
8=1+1+1+1+1+3
8=1+1+1+1+2+2
8=1+1+1+1+4
8=1+1+1+2+3
8=1+1+1+5
8=1+1+2+2+2
8=1+1+2+4
8=1+1+3+3
8=1+1+6
8=1+2+2+3
8=1+2+5
8=1+3+4
8=1+7
8=2+2+2+2
8=2+2+4
8=2+3+3
8=2+6

答案

12345678
12345687
12345768
12345786
12345867
12345876
12346578
12346587
12346758
12346785
12346857
12346875
12347568
12347586
12347658
12347685
12347856
12347865
12348567
12348576
12348657
12348675
1...

系统信息

exit code: 0, checker exit code: 0