Codeforces Beta Round #34 (Div. 2) C. Page Numbers

wp-page-numbers wordpress相关,非常好用的翻页导航。5种样式随便选择。 立即下载

C. Page Numbers
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants to print out (separates them with a comma, without spaces).

Your task is to write a part of the program, responsible for «standardization» of this sequence. Your program gets the sequence, keyed by the user, as input. The program should output this sequence in format l1-r1,l2-r2,...,lk-rk, where ri + 1 < li + 1 for all i from 1 to k - 1, and li ≤ ri. The new sequence should contain all the page numbers, keyed by the user, and nothing else. If some page number appears in the input sequence several times, its appearances, starting from the second one, should be ignored. If for some element i from the new sequence li = ri, this element should be output as li, and not as «li - li».

For example, sequence 1,2,3,1,1,2,6,6,2 should be output as 1-3,6.

Input

The only line contains the sequence, keyed by the user. The sequence contains at least one and at most 100 positive integer numbers. It's guaranteed, that this sequence consists of positive integer numbers, not exceeding 1000, separated with a comma, doesn't contain any other characters, apart from digits and commas, can't end with a comma, and the numbers don't contain leading zeroes. Also it doesn't start with a comma or contain more than one comma in a row.

Output

Output the sequence in the required format.

Sample test(s)
Input
1,2,3,1,1,2,6,6,2
Output
1-3,6
Input
3,2,1
Output
1-3
Input
30,20,10
Output
10,20,30

题目链接:http://codeforces.com/problemset/problem/34/C

题目大意:给一组数字,如果有连续的数字串比如1,2,3,4,就输出1-4,否则输出单个的数字,比如1,2,3,10,就输出1-3,10

解题思路:排序去重,模拟就行。输入格式处理一下。比较水的题~

代码如下:

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int a[105];
int main(void)
{
    int n=0,r=0,l=0;  //初始化左右下标
    char x;
    while(scanf("%d",&a[n++]))
    {
        scanf("%c",&x);
        if(x=='\n')    //若输入换行符,结束输入
            break;
    }
    sort(a,a+n);
    n=unique(a,a+n)-a;
    for(int i=1;i<n;i++)
    {
        if(a[i]==a[i-1]+1)  //如果连续,右下标加1
        {
            r++;
            continue;
        }
        else
        {
            if(r==l)
                printf("%d",a[l]);
            else
                printf("%d-%d",a[l],a[r]);
            r=i,l=i;
            printf(",");
        }
    }
    if(r>l)
        printf("%d-%d",a[l],a[r]);
    else
        printf("%d\n",a[l] );
    printf("\n",n);
}


PowerDesigner 数据库建模使用详解 阅读详情

相关推荐

新疆地形数据下载:30米、12.5米、5米DEM地形数据

新疆是我国陆地面积最大的省级行政区,总面积达166万平方公里。新疆的地形也十分的复杂,新疆的地形呈山脉与盆地相间排列,盆地被高山环抱,,俗称“三山夹两盆”。三山指阿尔泰山、昆仑山、天山,两盆是指塔里木盆地和准噶尔盆地。 对精度要求不高的话,可以直接使用图新地球下载 新疆30米地形数据 大小:9.26GB 来自ASTER v3的新疆30米地形数据 30米地形数据下载 新疆12.5米地形数据 12.5米DEM数据由于精度比较高,一般不会用到全省的数据,通常用的是一个地区的,因此,可以单独分

LocaSpace的博客 3505

B - Page Numbers

B - Page Numbers Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Description «Bersoft» company is working on a new

SHUI 507

三维模型转变为点云模型的好工具——CloudCompare使用小记

普通三维模型能够直观地展示物体的三维全貌,但是在一些场合需要将三维模型变为相应的点云模型进行展示,而使用激光雷达等传感器采集到的点云信息往往只能反应模型表面的情况,或是使用PCL库中的可执行文件进行转换,这两种操作较为麻烦。笔者最近就遇到了这样一个情况,找到了一个名叫CloudCompare(CC)的软件,能够支持将多种文件格式的三维模型转变为点云模型。以下将本人在使用过程中所使用到的一些操作简记下来供朋友们和将来的自己参考。 一、下载 CloudCompare是一款免费软件,其可以在CloudComp

hdlwyt的博客 2万+

Codeforces 34 C. Page Numbers

题目链接:http://codeforces.com/contest/34/problem/C«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print ou...

baodream的博客 336

医学影像处理实战:如何用Python+SimpleITK搞定DICOM/NIfTI重采样(附完整代码)

本文详细介绍了如何使用Python和SimpleITK库实现医学影像(DICOM/NIfTI格式)的智能重采样技术。通过实战代码演示,帮助读者掌握医学图像处理中的关键步骤,包括环境搭建、数据准备、核心算法实现和质量验证,解决医学AI领域中的影像标准化难题。

linux的博客 988

科研党必备:用MATLAB批量处理.mat文件数据的3种高效方法

本文为科研人员提供了使用MATLAB批量处理.mat文件数据的三种高效方法,涵盖智能数据加载、专业可视化与自动化报告生成。通过构建自动化框架、多维度数据画图策略及批量处理流程,帮助用户显著提升数据处理效率与图表专业性,解决海量实验数据的管理与分析难题。

weixin_29089057的博客 80

Page Numbers

«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence o...

Apollo的博客 696

灰度重心法实战:从原理到MATLAB代码实现激光条纹中心线提取

本文详细介绍了激光条纹中心线提取的核心方法——灰度重心法。通过物理类比阐释其原理,并提供从图像预处理到MATLAB代码实现的完整实战教程。文章重点解析了算法流程、关键参数调整及常见问题避坑指南,帮助读者快速掌握这一机器视觉与三维测量中的基础且高效的技术。

cake8的博客 472

微软word如何插入页码_如何在Microsoft Word中使用页码

微软word如何插入页码Microsoft Word offers an easy way to add different styles of page numbers to your document. If you’ve got a simple document, it works well enough. But if you’ve worked with Word for a whil...

culunyi0802的博客 2847

【PADS-开发指南】

馒头破戒大师

sinat_23896491的博客 3299

Android UI 组件系列(二):Button 进阶用法

在这篇博客中,我们深入探讨了 Button 的进阶用法,重点介绍了如何通过 事件处理 来响应用户的操作,如何使用 自定义样式 来提升按钮的外观,并利用 StateListDrawable 来管理按钮在不同状态下的表现。这些技巧能够帮助你打造更具交互性、视觉吸引力和动态响应的按钮,提升用户体验。

weixin_39339407的博客 1628

CodeForces 34C Page Numbers

Page Numbers Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 34C Description «Bersoft» company is working on a new ver

叶孤心的专栏 957

交换机端口模式详解:Access、Hybrid、Trunk

交换机是网络中至关重要的组件之一,用于连接各种设备并启用数据的高效流动。为了更好地管理和控制网络流量,交换机提供了不同的端口模式,其中包括Access、Hybrid和Trunk。本文将深入探讨这三种端口模式,详细解释它们的配置、特性和应用场景,以帮助网络管理员更好地理解和优化网络架构。

网络技术联盟站 4027

Codeforces Beta Round #34 (Div. 2)——C

C. Page Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output «Bersoft» company is working on a new versi

Learn as if you were to live forever 687

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

Page Numbers(字符串)

«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants to print out.

m0_51344983的博客 389

深度学习工具包 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&#39;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(&#39;DeepLearnToolbox&#39;));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(&#39;state&#39;,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&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,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 = &#39;sigm&#39;;%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, &#39;Too big error&#39;);```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(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;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)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;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, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% 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&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 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, &#39;Too big error&#39;);```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(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % 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, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);%% 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(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Codeforces 34C-Page Numbers(set+vector+暴力乱搞)

C. Page Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output «Bersoft» company is working on a new versi

Orz~~Orz 1321

WP Page Numbers – wordpress分页导航插件使用方法与教程

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_33989058的博客 1171

HBase分页查询---指定PageNumber和PageSize

问题:通过指定的页码和每页记录的条数来进行分页查询。 分析问题: 要实现分页查询,因为查询的是一个范围,所以使用Scan的查询方式。然后还使用PageFilter,这样能够获取指定数量的记录。 那么问题来了,要使用scan的方式进行区间查询那么startRow是什么??? 所以现在将问题转换成了求每一页的startRow !!! 当我们使用scan查询又没有指定StartRow的时候,结...

_a_0_ 1万+

word文档显示{page/numbers}不显示数字

word文档显示{page/numbers}不显示数字 Ctrl+A全选之后,shift+F9,,就可以了

echoguz的博客 2521

CodeForces 34C Page Numbers

#include #include #include #include #include #include #include #include #include #include #define inf 0x3f3f3f3f #pragma comment(linker, "/STACK:16777216") #define eps 1e-6 #define ll long l

Unknown 820

JQuery EasyuidataGrid控件获取pageSize,pageNumber等方法

1.  获取datagrid当前页码跟页面记录数的方法为: 第一种写法  :     currPageNumber:代表第几页       currPageSize:代表currPageNumber那一页的数据条数     获取页码:var currPageNumber = $("#dg" ).datagrid("getPager" ).data("pagination" ).optio...

Thinkingcao的专栏 1万+

codeforces 538 B.Quasi Binary(思维题)

B. Quasi Binary time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A number is called quasibinary if its decim

ysCover 1705

The 2014 ACM-ICPC Asia Regional Contest Xi'an Site K ast Defence

ProblemK. Last Defence Description Given two integersA and B. Sequence S is defined as follow: • S0 = A • S1 = B • Si = |Si−1 −Si−2| for i ≥ 2 Count the number ofdistinct numbe

ysCover 1131

CSU 1217 奇数个的那个数(异或)

1217: 奇数个的那个数 Time Limit: 2 Sec  Memory Limit: 1 MB Submit: 523  Solved: 120 [Submit][Status][Web Board] Description 给定些数字,这些数中只有一个数出现了奇数次,找出这个数。 Input 每组数据第一行n表示数字个数,1 接下来n行每行一个32位

ysCover 1114

Codeforces Round #105 (Div. 2) B. Escape

B. Escape time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The princess is going to escape the dragon's cave, and she

ysCover 1014

Codeforces Round #313 (Div. 2) C. Gerald's Hexagon(补大三角形)

C. Gerald's Hexagon time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Gerald got a very curious hexagon for his birthda

ysCover 1011
上一篇: ACM ICPC 2011–2012, NEERC, Northern Subregional Contest J. John’s Inversions(合并排序求逆序数对数)
下一篇: POJ 1062 昂贵的聘礼
雨狮子
博客等级 码龄12年 24粉丝 185原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址