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);
}


“挑战杯”大赛“揭榜挂帅”赛道-baseline解析 在这个脚本中,txt文件的保存路径为'yolov7/datasets/Fatigue_driving_detection/txt_labels/',而xml文件的路径为'./label_xml/'。标注图片后的产物是会给每一个图片对应生成一个xml格式的文件,但是如果要用yolo框架去训练模型,输入的数据必须是txt格式,因此这里有一步转换格式的过程。注意看:obs这里有三个文件夹,第一个是关键帧的文件夹A,第二个是标注时输出的位置为文件夹B,第三个是智能标注后和手动标注的合集文件夹C。 阅读详情

相关推荐

差分分析.

差分分析是一种强大的密码攻击技术,通过研究明文差分与密文差分的关系来破解加密算法。本文系统介绍了差分分析的核心概念和方法: 基础差分分析:通过异或运算抵消密钥影响,利用差分分布表(DDT)寻找高概率差分特征,以FEAL-4为例展示了具体攻击过程。 高级差分技术:包括截断差分分析(关注部分特征)、不可能差分分析(排除概率为0的路径)和飞来去器分析(将算法分段处理)。 自动化搜索方法:介绍了松井算法和MILP(混合整数线性规划)方法,将差分路径搜索转化为数学优化问题。 这些方法展现了差分分析从基础理论到现代应用

weixin_61562383的博客 792

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

YOLO11实战 第010期-基于yolo11的农业杂草作物目标检测实战文档(详细教程)

通过这条曲线,用户可以评估模型的检测能力,分析模型在不同阈值下对真实目标的检测是否全面。通过这条曲线,可以评估模型在目标检测任务中的整体性能,并找到合适的置信度阈值,以在精确率和召回率之间做出最佳平衡。PR 曲线越接近右上角,模型性能越好,曲线下方的面积越大,说明模型在不同置信度下的。),它展示了不同置信度下的召回率。条曲线都显示了随着召回率的增加,精确度略有下降的趋势,但整体上精确度保持在很高的水平。通过这条曲线,可以选择合适的置信度阈值,以优化模型的检测结果,平衡精确率和召回率。反映了分类器的准确性。

深度学习算法工程师,专注于前沿算法研究与实战应用。在这里,我将分享深度学习领域的实战经验、优质数据集资源以及最新论文解读与精度分析,旨在与广大技术爱好者共同探索人工智能的奥秘,助力技术成长与创新。 1528

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

保姆级教程:用C++逆向解析通达信shm.tnf文件(附完整代码与偏移量详解)

本文提供了一份详细的C++逆向工程教程,指导开发者如何解析通达信的shm.tnf文件。通过分析文件结构、定位关键字段并实现完整解析流程,帮助量化交易开发者高效获取沪市股票数据。教程包含完整代码示例和偏移量详解,适合金融数据本地化处理需求。

weixin_27945229的博客 532

V.PhyloMaker实战:从物种列表到维管束植物系统发育树的完整流程

本文详细介绍了使用V.PhyloMaker工具包,从物种列表快速构建维管束植物系统发育树的完整实战流程。内容涵盖R包安装、物种名标准化、核心函数phylo.maker的三种构建方案选择、结果树的可视化与导出,以及与picante包的联动分析,为生态学和生物地理学研究提供了高效解决方案。

weixin_29057237的博客 387

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的博客 693

FUMA实战:5分钟搞定GWAS数据中的Independent SNPs和Lead SNPs筛选

本文详细介绍了如何使用FUMA平台快速筛选GWAS数据中的Independent SNPs和Lead SNPs。通过解析核心概念、分步实战演示和结果解读,帮助研究人员在5分钟内从海量显著关联位点中提炼出独立且具代表性的遗传信号,为后续功能注释和基因定位奠定高效基础。

weixin_29201859的博客 437

微软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的博客 2844

【AUTOSAR AP PHM 】PHM 标准化“检查点上报接口”落地指南(AUTOSAR AP · R24-11取向)

本文介绍了AUTOSAR AP R24-11标准下PHM(平台健康管理)模块中"检查点上报接口"的标准化实现方案。主要内容包括: 核心设计理念:采用"配置优先"原则,通过部署模型预先定义监管参数,应用进程只需简单上报枚举标识,具体判定由PHM执行。 职责划分: 应用进程:仅调用ReportCheckpoint接口上报枚举值 PHM:负责Alive计数、Deadline区间判定和Logical路径校验 EM/IdsM:提供进程状态和越权检测 三类监管机制: Alive:

探索C++编程的奥秘,分享深入的技术见解和实践,旨在激发读者创造力与解决问题的思维。 224

OPPO 后端校招面试,过于简单了!

你好,我是 Guide。2026 届秋招陆续开奖公司的越来越多了,今天来看一家手机厂 OPPO。前几天,已经分享了和今年校招开奖的情况。其中,小红书的薪资最为炸裂,大白菜一年都能给到 51w+。不过,相对应的工作强度和压力也是真的难顶,确实很难有钱多又轻松的活!OV (OPPO 和 Vivo)这几年发展真还可以的,这两家的高端机口碑都不错。本人也是最近入手了一款 Vivo 的上一代旗舰,拍照是真的不错啊!每个月会有 1.2k 生活补贴,生活费是按照 8 % 缴纳。

JavaGuide 757

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

叶孤心的专栏 956

vue3 - vite报错TypeError: crypto.hash is not a function(vue3+vite启动运行提示错误,项目无法启动且打包报错失败,详细解决排查方案教程)

vue3 vite 报错,vue3+vite启动报错:TypeError: crypto.hash is not a function,创建vue3+vite项目时报错TypeError: crypto.hash is not a function,如何解决这个问题,VUE3+VITE报错crypto.hash,vue3运行报错,vite运行报错,vue3打包报错,vite打包报错,vue3新建项目无法运行,vue3 vite创建项目直接报错了,node版本不兼容,修改了node版本还是不行,依旧报错,一直

✅ 精选推荐文章 1万+

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

假人有限元模型

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

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

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

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

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

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

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 819

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

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

Thinkingcao的专栏 1万+

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

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

echoguz的博客 2519

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

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

_a_0_ 1万+

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

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

weixin_33989058的博客 1169

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 1704

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 1112

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 1013

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、付费专栏及课程。

余额充值