PAT 1038. Recover the Smallest Number

Qt OpenGL 3D 点云数据显示 在Qt中使用OpenGL显示3D点云数据是一个常见的需求,特别是在计算机视觉、机器人学和三维重建等领域。下面我将介绍一个基本的实现方案。 阅读详情

题目:http://pat.zju.edu.cn/contests/pat-a-practise/1038

题解:

代码:

#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
using namespace std;
struct ch
{
    char s[15];
}str[10005];
bool cmp(const struct ch &a,const struct ch &b)
{
    char tmpa[30],tmpb[30];
    strcpy(tmpa,a.s);
    strcpy(tmpb,b.s);
    strcat(tmpa,b.s);
    strcat(tmpb,a.s);
    return strcmp(tmpa,tmpb)<0;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; ++i)
        scanf("%s",str[i].s);
    sort(str,str+n,cmp);
    bool flag=false;
    for(int i=0; i<n; ++i)
    {
        for(int j=0; str[i].s[j]!='\0'; ++j)
        {
            if(!(flag==false&&str[i].s[j]=='0'))
            {
                flag=true;
                printf("%c",str[i].s[j]);
            }
        }
    }
    if(flag==false) printf("0");
    printf("\n");
    return 0;
}

来源: http://blog.youkuaiyun.com/acm_ted/article/details/20172431

【异常】OpenClaw 项目 `fetch failed` 报错问题排查与解决方案Response interrupted: TypeError: fetch failed 针对无超时控制、异常兜底缺失导致的请求中断,封装标准化的安全请求工具,一次性解决超时控制、异常捕获、日志埋点三大问题,全项目替换原生。:将项目运行的 Node.js 版本升级至 18.x 及以上 LTS 版本,使用 Node.js 内置的稳定版。实现的网络请求环节,包括但不限于:第三方开放接口调用、内部服务接口通信、跨域资源请求、外部配置拉取等场景。:针对无法升级 Node.js 版本的存量环境,通过社区稳定兼容包替换原生。类型异常,直接造成业务请求响应中断。第二步:业务代码改造,替换原生。 阅读详情

相关推荐

激光雷达+相机标定避坑指南:手把手教你用KITTI数据完成坐标转换

本文详细介绍了激光雷达与相机标定的实战指南,利用KITTI数据集完成精准坐标转换。从数据准备、工具链搭建到标定矩阵加载与验证,再到坐标转换流水线的工程实现,提供了全面的避坑技巧和工程实践建议。特别强调了多传感器融合中的常见问题及解决方案,帮助开发者提升自动驾驶和机器人感知系统的环境感知精度。

book8的博客 835

pat 1038 Recover the Smallest Number

这题明显是贪心的策略,但是排序算法一直没写好,费了我几个小时。后来发现,有个博客http://ppcool.iteye.com/blog/1731427 里面的排序好简单呀,好受打击。回宿舍继续舔伤口。 /* * pat_1038.cpp */ #include #include #include #include using namespace std; #define N 100

水人的专栏 2159

手把手教你为STM32设备生成自定义MAC地址(基于芯片ID的5种算法对比)

本文详细介绍了基于STM32芯片ID生成自定义MAC地址的5种算法,包括直接截取、异或折叠、CRC32哈希、自定义混合运算及SHA-256摘要。通过对比分析各算法的计算复杂度、唯一性及适用场景,帮助嵌入式开发者根据项目规模与资源,选择最合适的方案,确保设备MAC地址的唯一性与合规性。

weixin_29170327的博客 527

1038 Recover the Smallest Number (30分)--PAT甲级真题

Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can recover many numbers such like 32-321-3214-0229...

Samson的博客 297

初识colmap

COLMAP是一款开源的计算机视觉软件,主要用于从一系列二维图像中进行三维重建。它全称为“COLLISION-MAPping”,是一个高度集成的Structure-from-Motion (SfM) 和 Multi-View Stereo (MVS) 管道工具,由斯坦福大学开发和维护。COLMAP的主要功能包括特征检测与匹配、增量式SfM、多视图立体匹配以及优化。它能够从无序或有序的二维照片集合中恢复出三维场景的几何结构(点云)以及每张图像对应的相机姿态。

Hhsjehejj的博客 5551

Jenkins+docker 微服务实现自动化部署安装和部署过程

本文详细介绍了如何使用Docker部署Jenkins自动化服务器。主要内容包括:1)拉取Jenkins官方或BlueOcean镜像;2)创建容器并配置端口映射、数据卷挂载;3)设置防火墙规则;4)配置清华大学镜像加速;5)安装必要插件;6)SSH密钥配置;7)构建触发器设置;8)编写自动化构建脚本。通过Docker部署Jenkins可以简化安装流程,确保环境一致性,并利用容器特性实现快速启动和管理。文章提供了完整的配置步骤和注意事项,帮助用户快速搭建CI/CD环境。

qq_33665793的博客 1687

【PAT甲级】1038 Recover the Smallest Number (30 分)【贪心,排序】

【PAT甲级】1038 Recover the Smallest Number (30 分)【贪心,排序】 思路 给你一串数字,让你进行排列,问你怎么排可以得到最小值,比如数组 {32,321,3214,0229,87},可以排列成32-321-3214-0229-87 或 0229-32-87-321-3214 暴力做法可以做,但是最好还是写一个排序函数,用vector存储所有的string类型的字符串,然后根据以下比较规则进行排序:return a+b<b+a;,这样就可以得到最小的数 要注意

郭同学如是说 186

Lattice FPGA 开发工具Diamond使用流程总结——工具使用

本文介绍了一般的Diamond开发流程,包括工程创建、文件输入、IP使用、约束、管脚分配、和布线布局等流程

weixin_41895751的博客 2万+

浙大PAT 1038题 1038. Recover the Smallest Number

快排飘过 #include #include #include int cmp(const void *m,const void *n){ char *a=(char *)m; char *b=(char *)n; char tmpa[20],tmpb[20]; strcpy(tmpa,a); strcpy(tmpb,b); strcat(tmpa,b); strca

Sup_Heaven的专栏 1796

告别玄学调参:手把手教你用LSTM-AutoEncoder为传感器数据做异常检测(实战篇)

本文详细介绍了LSTM-AutoEncoder在传感器数据异常检测中的工程化实践,包括数据预处理、模型架构设计和生产环境部署策略。通过结合LSTM的时间序列处理能力和AutoEncoder的特征提取优势,该方法能够有效识别温湿度、PM2.5等传感器数据的异常模式,适用于工业物联网和室内空气质量监测等场景。

weixin_29212429的博客 477

天气预测模型:基于时间序列分析的数学建模与实战案例

目录引言时间序列分析介绍使用Matlab进行天气预测实战案例:天气预测结论天气预测一直是气象学和相关领域的重要研究问题之一。数学建模是进行天气预测的有效方法之一,其中时间序列分析是常用的技术。在本篇博客中,我们将介绍时间序列分析的基本原理,演示如何使用Matlab进行模型建立和预测,并通过一个实战案例来展示模型的应用和分析。时间序列分析是一种用于分析和预测时间序列数据的统计方法。天气数据通常具有时间依赖性和随机性,因此时间序列分析可以帮助我们了解天气的变化趋势和规律,并提供对未来天气的预测。时间序列分析通常

YOLO 1546

PAT 1038 Recover the Smallest Number

#include <iostream> #include <algorithm> #include <vector> using namespace std; bool cmp(string& s1,string& s2){ string a=s1+s2; string b=s2+s1; return a<b; }...

weixin_42379312的博客 155

Jetson Nano之CSI摄像头操作方法

jetson端csi摄像头的应用方法

ZONGXP的博客 1万+

PAT A1038 Recover the Smallest Number ——醉里挑灯看剑

PAT A1038 Recover the Smallest Number 犯的错误在于只考虑了第一个数字的前导0,以及结果为零的时候没有输出,应该是把最终结果的前导0都抹掉,如果都抹没了就输出0,但是只挂了一个测试点,恩,测试点考虑不周~ cmp的想法就是逐位比较两个数,当发现有一位不相等时,把小的排在前面,此时会有两个数位数不同的情况,经过模拟发现可以把短的循环使用,比如32和321,32扩展成3232,所以跟1比较的应该是3;32和323212,32扩展成323232,所以323212胜出 但是看过

weixin_40852534的博客 267

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

PAT 甲级 1038 Recover the Smallest Number

Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can recover many numbers such like 32-321-3214-0229...

lovingchq的博客 232

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

PAT 甲级 1038  Recover the Smallest Number

1038 Recover the Smallest Number (30 point(s)) Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can...

漫浸天空的雨色的备忘录~ 712

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

PAT1 1038 Recover the Smallest Number

题目链接 我的github 题目大意 给出一些数字字符串,现在要求将这些字符串连接,使得连接后的字符串最小 输入 每组包含一个测试用例, 每个用例会给一个正整数N≤104N \leq 10^4N≤104,然后跟着NNN个长度不超过8的数字字符串 输出 对每个测试用例输出连接后所能得到的最小的字符串,要求第一位不能是0,如果全为0就只输出一个0 样例输入 5 32 321 3214 0229 87...

LSC_333的博客 292

PAT 甲级 1038 (Recover the Smallest Number )

PAT 甲级 1037题目要求翻译代码思路 题目要求 Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can recover many numbers such like 32-321-3214-0229-87 or 0229-32-87-321-3214 wi

qq_42865772的博客 280

【PAT甲级 - C++题解】1038 Recover the Smallest Number

📣专栏定位:为想考甲级PAT的小伙伴整理常考算法题解,祝大家都能取得满分!

Newin2020的博客 359

[C++] PAT 1038 Recover the Smallest Number (30分)

Sample Input: 5 32 321 3214 0229 87 Sample Output: 22932132143287 题解: 参考了大佬的代码 1.以字符串接收数据, 2.之后对字符串数组进行排序,采用了贪心策略, 3.最后将字符串数组进行拼接为字符串s,得到最小的数, 4.注意是以非0开始,若s.length() == 0直接输出0 #include <iostream> #include <string> #include <algorithm&gt.

快乐de约定的博客 1994

PAT1038. Recover the Smallest Number

#include <stdio.h> #include <algorithm> #include <iostream> #include <string> #include <string.h> using namespace std...

chinawilliam2008的博客 136

PAT A1038 Recover the Smallest Number

PAT A1038 Recover the Smallest Number Sample Input: 5 32 321 3214 0229 87 Sample Output: 22932132143287 word meaning Recover 恢复 a collection of number segments 一组数字段 combinations n. [数]...

qq_42347617的博客 201

[排序]PAT1038 Recover the Smallest Number

题意:给出多个最长8位的数字,求他们组成的最小数字。 思路:这个想法比较简单了,假设两个数字字符串是str1,str2,直接排序排序规则是 str1+str2<str2+str1,可以得到最小的组合数字,注意要去掉前导0,如果全是0则只留下一个0。

九问的烦恼 1200

PAT自主训练记录 甲级1038 Recover the Smallest Number

1038 Recover the Smallest Number (30分) 题目描述 Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can rec...

19821220的博客 213

PAT 1038. Recover the Smallest Number (30)

1038. Recover the Smallest Number (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a collection of number s

FrozenShore 441
上一篇: PAT 1040. Longest Symmetric String
下一篇: PAT 1010. Radix
ACM_Ted
博客等级 码龄15年 122粉丝 208原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值