NYOJ--19--next_permutation()--擅长排列的小明
来源:互联网 发布:mac jenkins 配置文件 编辑:程序博客网 时间:2024/06/13 11:26
/*Name: NYOJ--19--擅长排列的小明Author: shen_渊 Date: 20/04/17 11:06Description: 这道题可以DFS,然而用next_permutation更简单些主要是全排列,将所有字符串考虑到后,只输出前m个字符 */#include<bits/stdc++.h>#include<cstdlib>using namespace std;int arr[10] = {1,2,3,4,5,6,7,8,9};int main(){//freopen("in.txt","r",stdin);ios::sync_with_stdio(false);int N;cin>>N;while(N--){int n,m;cin>>n>>m;string str = "";for(int i=0;i<n;++i)str+='0'+arr[i];string str1,str2 = str.substr(0,m);cout<<str2<<endl;while(next_permutation(str.begin(),str.end())){if((str1 = str.substr(0,m))!= str2){str2 = str.substr(0,m);cout<<str2<<endl;}} }return 0;}
0 0
- NYOJ--19--next_permutation()--擅长排列的小明
- nyoj 19 擅长排列的小明 【next_permutation() 】
- NYOJ 19 擅长排列的小明 (STL之next_permutation()的使用)
- NYOJ 19 擅长排列的小明(dsf STL——next_permutation函数)
- NYOJ19 擅长排列的小明【next_permutation】
- 擅长排列的小明(next_permutation)
- NYOJ 19 擅长排列的小明
- NYOJ 19-擅长排列的小明
- nyoj 19 擅长排列的小明
- nyoj 19 擅长排列的小明
- nyoj-19-擅长排列的小明
- nyoj 19 擅长排列的小明
- nyoj 19【擅长排列的小明】
- NYOJ 19 擅长排列的小明
- NYOJ 19(擅长排列的小明)
- NYOJ---19擅长排列的小明
- nyoj 19 擅长排列的小明
- NYOJ 19 擅长排列的小明
- 如何获取Android手机连接网络的当前局域网IP
- Boost install on Ubuntu
- vue---todolist
- Map集合的两种遍历方式
- [SMOJ1809]乌龟棋
- NYOJ--19--next_permutation()--擅长排列的小明
- jqgrid清楚单元格内容
- 58同城 iOS客户端组件化演变历程---公司也正朝着这个方向努力
- Linux curl命令详解
- Set up the Virtual switch and Virtual adapter in Windows 2012R2
- Python 机器学习过程小结
- Java7里try-with-resources分析
- $.param()
- Vue.js做todo日常事务任务列表