UVA 10474 - Where is the Marble?

Python刷OJ———UVa :10474 Where is the Marble? 首先说一下,本人没有投身ACM的想法,刷题完全是当练习,有些题能accept,其余基本都是LTE。。讲真的,全网太难找到用python实现的代码了,而我就是如此倔强,于是放一些题的代码在博客上,纯属爱好,大家不要当真哈哈哈哈。 ———————————————————————————————————————————— 题目: Raju and Meena love to play with Marb... 阅读详情

      主要利用题目中的条件,并不需要排序。因为出现的数不超过10000。只需要统计0 - 10000出现数的个数,就可以确定出现数的排名。

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {
    int n, q;
    int que[10005];

    int count = 1;
    while (scanf("%d%d", &n, &q) && n && q) {
        memset(que, 0, sizeof (que));

        int maxn = 0, tmp;
        for (int i=0; i<n; i++) {
            scanf("%d", &tmp);
            que[tmp]++;
            maxn = maxn < tmp ? tmp : maxn; // 记录下出现的最大数
        }
        tmp = 0;
        for (int i=0; i<=maxn; i++) {
            if (que[i]) {
                tmp += que[i];
                que[i] = tmp-que[i]+1;
            }
        }

        printf("CASE# %d:\n", count++);
        for (int i=0; i<q; i++) {
            scanf("%d", &tmp);
            if (que[tmp]) {
                printf("%d found at %d\n", tmp, que[tmp]);
            }
            else {
                printf("%d not found\n", tmp);
            }
        }

    }

    return 0;
}


 

UVA10474 Where is the Marble? UVA 10474 立即下载

相关推荐

忘记安卓锁屏密码怎么办?3种方法教你用ADB恢复访问(含gesture.key解密)

本文详细解析了安卓设备锁屏密码的存储与加密机制,特别是gesture.key文件的解密原理。针对遗忘密码的常见问题,提供了三种核心恢复方法:利用ADB调试接口删除密码文件、对gesture.key进行离线分析与解密,以及应对高版本系统的替代方案。重点介绍了通过ADB工具在Recovery模式下操作的具体步骤,帮助用户在合法合规前提下恢复设备访问权限。

php55的博客 959

UVA10474 Where is the Marble?【排序】

Raju and Meena love to play with Marbles. They have got a lot of marbles with numbers written on them. At the beginning, Raju would place the marbles one after another in ascending order of the number...

海岛Blog 4614

Ubuntu下Vim创建属于自己的头部注释和代码模板

痛点 每次打开vim想写个C或者C++的程序都要把固定的模板敲一遍,是不是感觉非常的繁琐,能不能把Vim弄得像IDE那样新建一个文件直接生成对应的头部注释和代码模板,减少这些重复工作呢?下面我尽量详细的介绍实现的方法: 先看看新建文件后的效果 C语言格式效果 C++语言效果 方法: 使用命令 vi /etc/vim/vimrc 打开vimrc这个文件,然后复制以下代码至文件末尾的空白处即可! 修改vimrc文件里面的内容必须要用root管理员身份才能进行修改,修改时先切换至root身份即可。 "新建.

weixin_42137584的博客 1561

10474 - Where is the Marble?

Where is the Marble?  Raju and Meena love to play with Marbles. They have got a lotof marbles with numbers written on them. At the beginning, Rajuwould place the marbles one after another i

Fourth Dimension 1477

Simulink实战:5步搞定固定翼飞行器六自由度动力学建模(附模型下载)

本文提供了一份详细的Simulink实战指南,通过5个核心步骤手把手教你构建固定翼飞行器的六自由度动力学模型。内容涵盖从顶层架构设计、核心方程手动实现,到模型集成、测试调试及进阶优化的完整流程,旨在帮助航空航天学生和工程师将抽象理论转化为可运行的仿真模型,并附有模型下载。

perl8的博客 634

Open3D(C++) 基于RANSAC和TLS的点云平面拟合

针对点云平面拟合过程中出现的异常值及误差的问题,提出一种将随机采样一致算法(RANSAC)与整体最小二乘法(TLS)相结合的点云平面拟合方法。利用随机采样一致算法剔除异常值,利用整体最小二乘法对剩余有效点进行平面拟合,计算模型参数。实验结果表明,该方法与传统的特征值法、最小二乘法相比,能提高参数的估算精度,更适合对含有不同异常值及误差的点云数据进行拟合,是一种稳健的平面拟合方法。

点云侠的博客 431

uva 10474 Where is the Marble?(排序)

uva 10474 Where is the Marble? Raju and Meena love to play with Marbles. They have got a lot of marbles with numbers written on them. At the beginning, Raju would place the marbles one afte

总有那么一群人喜欢盯着我的博客看,估计这是他们见过最长的博客名,我必须得告诉他们博客名最长可以写多长 731

时间序列分析(Time Series Analysis) 原理与代码实例讲解

时间序列分析(Time Series Analysis) - 原理与代码实例讲解 作者:禅与计算机程序设计艺术 / Zen and the Art of Computer Programming 关键词:时间序列预测,ARIMA模型,状态空间模型,SARIMA模型,机器学习

AI天才研究院 1246

UVa10474.Where is the Marble?

题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1415 13887483 10474 Where is the Marble? Accepted C++ 0.548 2014-07...

banxuanliu0005的博客 167

【AVRCP】规范精讲[19]: 媒体属性全解析,让你的蓝牙设备显示完整歌曲信息

AVRCP协议中的媒体属性是蓝牙音频设备传输歌曲元数据的关键,包含标题、艺术家、专辑等32位ID标识的键值对信息。规范要求字符串属性必须使用UTF-8编码,但乱码问题频发(如中文显示异常),主因是设备未遵循编码标准或使用GBK等非规范格式。常见问题包括信息不全(仅显示标题)、封面缺失(因带宽限制或格式不支持)及更新延迟(通知机制未启用)。解决方案包括强制UTF-8编码、优化封面大小(如300x300像素JPEG)、主动请求缺失属性。Android示例代码展示了通过广播接收器解析媒体属性的方法。

byte轻骑兵的技术小窝 1万+

【Python搞定车载自动化测试】——Python实现车载以太网DoIP刷写(含Python源码)

随着智能电动汽车行业的发展,汽车=智能终端+四个轮子,而人工智能也发展越来越快,Python语言使用越来越广,本章节主要介绍如何使用Python语言基于Pytest自动化框架来实现DoIP诊断自动化测试。首先回顾一下DoIP诊断基础知识:DoIP(Diagnosis over Internet Protocol)是一种用于车辆诊断的网络通信协议。它基于现代互联网技术,允许通过以太网或IP网络进行车辆诊断和通信。

测试领域技术分享 3795

UVA 10474-Where is the Marble?

UVA 10474-Where is the Marble?题目大意:先输入 2 个数字,一个是被查找的元素个数,一个是需要查找的元素个数,然后输入元素,如果输入 0 则结束,然后将被查找元素排序后查找解题思路:先排序,然后找出元素所在位置#include <stdio.h> #include <iostream> using namespace std; int main() { int

ZeroLH00的博客 379

三维重建(十三)——多视角重建

本文综述了多视角三维重建技术,涵盖静态和动态场景的重建方法。介绍了从图像获取到纹理映射的SFM流程,以及非刚性重建(NRSFM)的挑战和解决方案。重点探讨了基于可微渲染的重建方法,以及数据采集策略、相机标定和同步技术。文章还讨论了如何用单视角相机模拟多视角重建,总结了关键技术和未来研究方向。

河海大学研究生在读的学习笔记 1058

0018 Where is the Marble? UVA - 10474

0018 Where is the Marble? UVA - 10474

算法竞赛入门,越专注,越成功。 183

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

UVa 10474 Where is the Marble?

/* coder: ACboy date: 2010-2-25 result: 1AC description: UVa 10474 Where is the Marble?*/#include #include #include using namespace std;int main(){ int i, j; int N, Q;

个人独立博客http://www.acb0y.cn/ 1016

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

Where is the Marble? UVA - 10474

Where is the Marble? UVA - 10474Raju and Meena love to play with Marbles. They have got a lot of marbles with numbers written on them. At the beginning, Raju would place the marbles one after another

BackToMe的博客 418

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

UVA 10474 Where is the Marble?

题目链接:UVA 10474 Where is the Marble?  Where is the Marble?  Raju and Meena love to play with Marbles. They have got a lot of marbles with numbers written on them. At the beg

一蓑烟雨 407

UVA 10474 Where is the Marble?(

UVA 10474  Where is the Marble? 这题的题意就是找到第几小的,注意数组的范围; #include #include int com(const void *a1,const void *a2) { return *(int *)a1-*(int *)a2; } int main() { int n,m; int i,j,k=1; int s[20000];

纯纯的心儿的专栏 437

UVa 10474 Where is the Marble?(大理石在哪儿)

UVa 10474 Where is the Marble?(大理石在哪儿) UVa题目链接 题目名称:大理石在哪 题目描述: 现有N个大理石,每个大理石上写了一个非负整数,首先把各数从小到大排序,之后回答Q个问题,每个问题问是否有一个大理石写着某个整数x,如果是,还要回答哪块大理石上写着x,排序后的大理石从左到右编号为1~N。 样例输入: 4 1 2 3 5 1 5 5 2

Voidwalkerxiaohui 1696

【每日一题(17)】Where is the Marble? UVA - 10474

Where is the Marble? UVA - 10474 Raju and Meena love to play with Marbles. They have got a lot of marbles with numbers written on them. At the beginning, Raju would place the marbles one after

Winsoul Blog 1万+
上一篇: UVA 10420 - List of Conquests
下一篇: UVA 152 - Tree's a Crowd
zcube
博客等级 码龄17年 170粉丝 120原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值