POJ 1520 C++

3D坐标系转换实战:如何用Python快速实现旋转矩阵与平移向量的组合变换 本文详细介绍了如何使用Python和NumPy实现3D坐标系转换中的旋转矩阵与平移向量的组合变换。通过齐次坐标和变换矩阵的数学原理,结合代码示例,帮助开发者高效处理机器人路径规划和计算机视觉中的空间变换问题,并解决实际应用中的常见错误。 阅读详情

    不知道从哪里找来的题目分类里将这题放在了sorting这一类,看了一看,还是挺有意思的,于是就开始做了。

    题目输入的要求写得很模糊啊,都不知道最多有多少个单词输入,每个单词的最大长度是多少,处理起来还是挺麻烦的,要一行行地读进来,然后自己将里面的单词抽出来,方便进行排序。我用了一个长度为1000的char数组来存放一行输入,然后用一个长度为250的char指针数组来存放一行里面包含的单词。

    处理完输入,我采用了自己写的冒泡排序的变体来对单词进行排序。这里要注意题目的单词比较规则是不分大小写的,如果直接用string::strcmp函数进行比较的话,是会出现问题的。比如题目要求无论是大写的A还是小写的a都是要排在B或b前面的,如果直接用strcmp就会出现问题了,所以,最好还是自己写一个比较的函数吧,把要比较的字符串全部转化为大写或小写来比较,C程序员,自力更生是优良传统,呵呵。

    排序的思想和冒泡排序时一样的,就是交换的时候要用一个循环找到下一个数字或单词的位置来交换,当然也可以直接用qsort来进行排序,不过就需要先把数字和单词给单独分开了。提交之后发现效率还可以,156K,0MS,一次就AC了,自己都不敢相信~~~

    不多说了,直接贴代码吧。

 

    通过这道题,对C++的指针有了更深入的了解,不会像在Java中一样,只会用数组名引用了,也顺便复习了一下冒泡排序。自己写的冒泡排序也没有对交换次数进行优化,这题的输入也不是很大所以勉强混过去了,各位大牛肯定有更好的解法,还望不吝赐教。

 

 

Android性能分析深度指南:Perfetto工具全面解析 本文深入探讨Android性能优化工具Perfetto的应用与实践。作为Google推出的新一代追踪系统,Perfetto整合了CPU调度、内存分配、电池状态等多维度分析功能,通过高性能数据处理和可视化界面帮助开发者定位性能瓶颈。文章系统介绍了Perfetto的架构原理、配置方法和核心功能,包括CPU性能分析、内存泄漏检测等关键技术。通过电商应用卡顿优化的实战案例,展示了如何利用数学建模(如帧时间公式$T_{\text{render}}\leq16.67\text{ms}$)指导性能调优。 阅读详情

相关推荐

App渗透 - 人脸识别登录绕过

一、APP抓包和逆向破解加密算法打开APP是一个登录框抓包后发现参数被加密了使用Jadx脱源码发现,并没有加壳也没有混淆,运气很好根据经验,先搜索Encrypt、Decrypt等关键字,发现在Common.js中有一个encryptData函数定位过去,一套加解密算法都写好了放在这放到浏览器console里面调试,果然没错二、寻找注入点首先测试了一下注入明文:{"userName":"TEST'...

渗透测试研究中心 2836

c++_primer_exercise_1518_1519_1520

Exercise 15.18 15.19 15.20: class Base { public: void pub_mem(); void memfcn(Base &b) { b = *this; } protected: int prot_mem; private: char priv_mem; }; class Pub_drev : public Base

头像是我的偶像的专栏 1053

科研绘图神器Origin中文版安装后还是英文?手把手教你三步搞定界面汉化

本文详细介绍了Origin软件安装后界面仍显示英文的解决方案,包括基础语言切换、注册表修改和序列号破解三种方法。通过逐步指导,帮助用户快速实现界面汉化,提升科研绘图效率。特别针对教育版用户提供了有效的语言锁定解除方案。

weixin_42524708的博客 1183

poj1520

排序 View Code #include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; #define maxn 1005 #define...

weixin_34281537的博客 150

PRIDE PPP-AR软件实战:从ZTD解算到PWV反演的全流程避坑指南

本文详细解析了使用PRIDE PPP-AR软件进行GNSS数据处理的全流程,重点涵盖从ZTD解算到PWV反演的关键步骤与精度评估。文章深入剖析了软件部署、数据准备、参数配置中的常见“坑点”,并提供了与IGS ZTD及ERA5产品进行交叉验证的实用方法,旨在帮助用户高效、准确地获取高精度大气可降水量产品。

p8q9r0的博客 623

基于淘宝商城用户购物行为数据分析系统

本文使用HIve+superset技术对阿里云天池提供的淘宝用户购物数据进行处理分析,得到有价值的信息并对平台提出有建设性意义的意见。

m0_51388399的博客 2824

POJ 1520 Scramble Sort G++

给出数字和单词组成的列表。分别在数字的位置对数字进行排序和在单词的位置对单词排序。

woniupengpeng的专栏 712

CodeBuddy 接入 MCP,一键生成网站!

2024 年 11 月,Anthropic 公司搞了个挺有意思的新玩意 - Model Context Protocol(模型上下文协议)简称为 MCP 协议。简单来说,它就是给 AI 和各类工具数据之间搭了个标准化的”桥梁”,让开发者不用再为对接问题头疼了。mcp.so如下图所示,这是 mcp.so 网站中的 MCP Server。使用百度/高德地图分析旅线计算时间接 Puppeteer 自动操作网页使用 Github/Gitlab 让大模型接管代码仓库。

悟空聊架构的专栏 1957

poj1520scramble_sort

Scramble SortTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 1896 Accepted: 972DescriptionIn this problem you will be given a series of lists containing

万里晴空 1260

开关电源的纹波和噪声电压-抑制方法

开关电源(包括AC/DC转换器、DC/DC转换器、AC/DC模块和DC/DC模块)与线性电源相比较,最突出的优点是转换效率高,一般可达80%~85%,高的可达90%~97%;其次,开关电源采用高频变压器替代了笨重的工频变压器,不仅重量减轻,体积也减小了,因此应用范围越来越广。 但开关电源的缺点是由于其开关管工作于高频开关状态,输出的纹波和噪声电压较大,一般为输出电压的1%左右(低的为输出电压的0.5%左右),最好产品的纹波和噪声电压也有几十mV;而线性电源的调整管工作于线性状态,无纹波电压,输出的噪声电压也

ltqdxl的博客 1万+

C#串口通信从入门到精通(21)——一个串口多线程发送数据

本文详细介绍了串口通信中采用多线程发送串口数据的解决方案,由多年实战经验总结,绝对干货!

qq_34059233的博客 3699

poj完整分类

DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  1024   Calendar Game       简单题  1027   Human Gene Functions   简单题  1037   Gridland            简单题  1052   Algernon s Noxious

zhongkeli的专栏 7878

Android 中 app freezer 原理详解(二):S 版本

在之前的两篇博文《Android 中app内存回收优化(一)》和《Android 中app内存回收优化(二)》中详细剖析了 Android 中 app 内存优化的流程。这个机制的管理通过 CachedAppOptimizer 类管理,为什么叫这个名字,而不叫 AppCompact 等?freezer,一个针对应用进程长期处于 Cached 状态的优化。在之前博文《app freezer 原理 R 版本》

私房菜 3616

POJ1520

/*vecotr_change POJ1520*/ #include #include #include #include #include #include #include #include #define INT_MIN 0x80000000 #define INT_MAX 0xffffffff #define N 100 #define MAX(a,b) (a)>(b)?(

Laniakea 527

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

poj 2342 && hdu 1520

Anniversary party Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11261Accepted Submission(s): 4641 Problem Description There is goi...

daya1239的博客 134

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

poj 2342 hdu 1520【树形dp】

poj 2342 给出每个顶点的happy值,还有若干组两个顶点L,K关系,表示K是L的上司。求当K、L不同时出现时获得的happy值的最大和。 设dp[u][0]表示不选u结点时获得的最大值,dp[u][1]表示选u结点时获得的最大值。则有:    dp[u][0]+=max(dp[v][0],dp[v][1]),dp[u][1]+=dp[v][0](u为v的父节点) 当父亲节点用有向边...

weixin_34419326的博客 96

深度学习工具包 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")

poj2342&&hdu1520(树形dp)

链接:点击打开链接 题意:一个公司要组织一个派对,每个人有一个愉悦值,给出n个人每个人的愉悦值以及他们他们的直接上司,要求每一个人不能喝他自己的直接上司同时出现,输出愉悦值和的最大值 代码: #include #include #include #include #include #include using namespace std; int n; int f

stay_accept的专栏 504

Anniversary party(hdu1520)(poj2342)题解

原题地址:http://poj.org/problem?id=2342 题目大意:   上司和下属不能同时参加派对,求参加派对的最大活跃值。   关系满足一棵树,每个人都有自己的活跃值(-128~127)   求最大的活跃度。 树形DP入门题。 首先讲解一下树形DP,顾名思义,树形DP一定是在树上的DP,与普通的DP相似,具有两个方向。 1.根---->叶 ...

aikuaili4001的博客 161

POJ 1281 MANAGER

POJ 1281 MANAGER 1. 模拟题,按照题目的要求做即可,但是要细心,比较繁琐,尤其是边界问题; 2. 20分钟写完程序,但是WA了七八次,检查了一个小时,最后加上循环输入输出,居然AC了,欲哭无泪。 #include <iostrea...

dayong9372的博客 123

poj 2342 && hdu 1520 树形dp

题意:有n个人,接下来n行是n个人的价值,再接下来n行给出l,k说的是l的上司是k,这里注意l与k是不能同时出现的 链接:点我 dp[i][1] += dp[j][0], dp[i][0] += max{dp[j][0],dp[j][1]};其中j为i的孩子节点。 第二次做感觉已经很水了 1 #include<cstdio> 2 #include<...

weixin_30332705的博客 107

zoj 1520 Duty Free Shop

题意:Pedro有2种巧克力分别有m块和 l块,现在他有n个巧克力盒子,他希望把这n个盒子全都填满,要求每种盒子中只能包含有一种巧克力,巧克力可以有剩余,如果能填满,就输出第一种巧克力用了多少个盒子,并且输出盒子的序号,如果不能就输出Impossible to distribute 0,1背包 m[s]:表示s这个数能否被填满 m[s]=m[s]|m[s-d[i]] 求出第一种巧克力最多能

allblue 583

hdu1520 树形dp Anniversary party

A - Anniversary party Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1520 Description There is going to be a party to celebrat...

weixin_30575309的博客 97

poj2342&hdu1520Anniversary party【树型dp模板题】

Description There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor rela

MissZhou要努力 507

POJ2342 树行dp

题目链接:http://poj.org/problem?id=2342或者http://acm.hdu.edu.cn/showproblem.php?pid=1520 题目大意:一个公司里的人去参加聚会,每个人都有自己的happy值,参加聚会的人的happy值总和越高,聚会气氛越嗨。但是,直接的上下属不能同时在场,问聚会的最大happy值 设01表示在场状态,有方程: dp[i][0] ...

皮皮辉~ 225

poj2342—树形dp

华电北风吹 天津大学认知计算与应用重点实验室 日期:2015/9/15 poj上一道与动态规划特别像的题目(http://poj.org/problem?id=2342),一个公司要出席一些人员,每个人对应一个活跃度,要求是不能存在直属关系,活跃度最大。参考了别人的博客,很多人说这个是树形动态规划,我个人感觉应该划分到分治法里面(不存在重叠子问题)。 下面是我修改后的代码,采用递归的思路。例如计

掉下个小石头 748

HDU 1520 & POJ 2342 Anniversary party(树形dp)

Anniversary party Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Description There is going to be a party to celebrate the 80-th Anniversary of t

小夏 的博客 629
上一篇: POJ1423求n的阶乘 Java解题
下一篇: vim命令入门
canchew
博客等级 码龄17年 14粉丝 13原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值