acgo题库
  • 首页
  • 题库
  • 题单
  • 竞赛
  • 讨论
  • 排行
  • 团队
  • 备赛专区

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
登录
注册
题目详情题解(0)讨论(0)提交记录(0)
  • zuiyoujie(bushi

    #include<bits/stdc++.h> using namespace std; // 把选择的数字保存起来 int n,m; // 现在对于 num 数字到达 选 还是 不选 // 已经选择 take 个数字 void combination(int num,string take,int s){ if (num > n || take.size() >= m2+s){ // 应该结束递归 if (take.size() >= m2+s) cout << take << endl; return; } // 对于 num 进行选择 还是 不选择 // 如果选择 num 还应该做哪些事情 string a; int w=s; if(num >= 10){ a += num/10 + '0'; a += num%10 + '0'; w+=1; } else{ a += num + '0'; } a += ' '; combination(num + 1,take+a,w); // 不选择 num 这个数字 应该做哪些事情 combination(num + 1,take,s); } int main(){ cin >> n >> m; combination(1 , "",0); return 0; }

    userId_undefined

    苑首席·特乐

    倔强青铜
    2阅读
    0回复
    0点赞
首页