21281_PageCoun

2022-5-16 18:19| 发布者: Hocassian| 查看: 26| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-8950597572500-Problem List-采集的数据-后羿采集器.html

Pro.ID

21281

Title

Page Count

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21281

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 3000/1000 MS (Java/Others)     Memory Limit: 131072/65536 K (Java/Others)
  • 描述

    When you execute a word processor's print command, you are normally prompted to specify the pages you want printed. You might, for example, enter:

    10-15,25-28,8-4,13-20,9,8-8

    The expression you enter is a list of print ranges, separated by commas.

    Each print range is either a single positive integer, or two positive integers separated by a hyphen. In the latter case we call the first integer low and the second one high. A print range for which low > high is simply ignored. A print range that specifies page numbers exceeding the number of pages is processed so that only the pages available in the document are printed. Pages are numbered starting from 1.

    Some of the print ranges may overlap. Pages which are common to two or more print ranges will be printed only once. (In the example given, pages 13, 14 and 15 are common to two print ranges.)

    输入

    The input will contain data for a number of problem instances. For each problem instance there will be two lines of input. The first line will contain a single positive integer: the number of pages in the document. The second line will contain a list of print ranges, as defined by the rules stated above. End of input will be indicated by 0 for the number of pages. The number of pages in any book is at most 1000. The list of print ranges will be not be longer than 1000 characters.

    输出

    Description

    When you execute a word processor's print command, you are normally prompted to specify the pages you want printed. You might, for example, enter:

    10-15,25-28,8-4,13-20,9,8-8

    The expression you enter is a list of print ranges, separated by commas.

    Each print range is either a single positive integer, or two positive integers separated by a hyphen. In the latter case we call the first integer low and the second one high. A print range for which low > high is simply ignored. A print range that specifies page numbers exceeding the number of pages is processed so that only the pages available in the document are printed. Pages are numbered starting from 1.

    Some of the print ranges may overlap. Pages which are common to two or more print ranges will be printed only once. (In the example given, pages 13, 14 and 15 are common to two print ranges.)

    Input
    The input will contain data for a number of problem instances. For each problem instance there will be two lines of input. The first line will contain a single positive integer: the number of pages in the document. The second line will contain a list of print ranges, as defined by the rules stated above. End of input will be indicated by 0 for the number of pages. The number of pages in any book is at most 1000. The list of print ranges will be not be longer than 1000 characters.
    Output
    For each problem instance, the output will be a single number, displayed at the beginning of a new line. It will be the number of pages printed by the print command.
    Sample Input
    30
    10-15,25-28,8-4,13-20,9,8-8
    19
    10-15,25-28,8-4,13-20,9,8-8
    0
    Sample Output
    17
    12
    Source

    样例输入

    30
    10-15,25-28,8-4,13-20,9,8-8
    19
    10-15,25-28,8-4,13-20,9,8-8
    0

    样例输出

    17
    12

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部