uva 全排列题目 146 + 729 + 10098

简介: 解题思路:      对于全排列的问题,STL,提供了一个强大的函数,                                 bool   next_permutation(iterator.begin() ,  iterator.end());                        对于当前的序列如果不是最后一个序列则返回真,否则返回假。


解题思路:      对于全排列的问题,STL,提供了一个强大的函数,

                                bool   next_permutation(iterator.begin() ,  iterator.end());

                       对于当前的序列如果不是最后一个序列则返回真,否则返回假。


uva     10098 - Generating Fast 

题目链接: 点击打开链接

代码:
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

string str;
int main(){
    int n;
    scanf("%d" , &n);
    while(n--){
        string str;
        cin>>str;
        while(next_permutation(str.begin() , str.end())){
            cout<<str<<endl;
        }
        cout<<endl;
    }
    return 0 ;
}

uva  729 - The Hamming Distance Problem

题目链接:点击打开链接

代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main() {
    int Case , n, h;
    bool first = true;
    scanf("%d" , &Case);
    while(Case--){
        if(first)
          first = false;
        else
          printf("\n");
        string str;
        scanf("%d%d", &n, &h);
        for (int i = 0; i < n; i++) {
            if (i >= n - h)
               str += '1';
            else
               str += '0';
        }
        cout<<str<<endl;
        while (next_permutation(str.begin(), str.end()))
              cout << str << endl;
    }
    return 0;
}




uva  146 - ID Codes

题目链接:点击打开链接

代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;

string str;

int main(){
    while(cin>>str){
        if(str == "#")
            break;
        if(next_permutation(str.begin(),str.end()))
            cout<<str<<endl;
        else
            printf("No Successor\n");
    }  
    return 0;
}


目录
相关文章
|
机器学习/深度学习 缓存 并行计算
NVIDIA Tesla GPU系列P4、T4、P40以及V100参数性能对比
NVIDIA Tesla系列GPU适用于高性能计算(HPC)、深度学习等超大规模数据计算,Tesla系列GPU能够处理解析PB级的数据,速度比使用传统CPU快几个数量级,NVIDIA Tesla GPU系列P4、T4、P40以及V100是Tesla GPU系列的明星产品,云服务器吧分享NVIDIA.
84100 1
|
10月前
|
Devops Shell 网络安全
git使用之如何将一套代码同时推送至github|gitee|gitcode|gitlab等多个仓库-含添加ssh-优雅草央千澈完美解决-提供整体提交代码
git使用之如何将一套代码同时推送至github|gitee|gitcode|gitlab等多个仓库-含添加ssh-优雅草央千澈完美解决-提供整体提交代码
470 16
git使用之如何将一套代码同时推送至github|gitee|gitcode|gitlab等多个仓库-含添加ssh-优雅草央千澈完美解决-提供整体提交代码
|
API 定位技术
【高德地图API】那些年我们一起开发的APP—即LBS应用模式分享
原文:【高德地图API】那些年我们一起开发的APP—即LBS应用模式分享  摘要:利用地图API都能做些什么应用呢?应用商店里所有的分类,都可以结合上LBS来丰富应用。除了传统的生活服务应用,还有新潮的AR实景,可穿戴设备,甚至炫酷的游戏。
1947 0
|
22小时前
|
云安全 人工智能 安全
AI被攻击怎么办?
阿里云提供 AI 全栈安全能力,其中对网络攻击的主动识别、智能阻断与快速响应构成其核心防线,依托原生安全防护为客户筑牢免疫屏障。
|
10天前
|
域名解析 人工智能
【实操攻略】手把手教学,免费领取.CN域名
即日起至2025年12月31日,购买万小智AI建站或云·企业官网,每单可免费领1个.CN域名首年!跟我了解领取攻略吧~
|
4天前
|
安全 Java Android开发
深度解析 Android 崩溃捕获原理及从崩溃到归因的闭环实践
崩溃堆栈全是 a.b.c?Native 错误查不到行号?本文详解 Android 崩溃采集全链路原理,教你如何把“天书”变“说明书”。RUM SDK 已支持一键接入。
429 191
|
3天前
|
数据采集 消息中间件 人工智能
跨系统数据搬运的全方位解析,包括定义、痛点、技术、方法及智能体解决方案
跨系统数据搬运打通企业数据孤岛,实现CRM、ERP等系统高效互通。伴随数字化转型,全球市场规模超150亿美元,中国年增速达30%。本文详解其定义、痛点、技术原理、主流方法及智能体新范式,结合实在Agent等案例,揭示从数据割裂到智能流通的实践路径,助力企业降本增效,释放数据价值。