22055_StuPId

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

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

Pro.ID

22055

Title

StuPId

Title链接

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

AC

20

Submit

40

Ratio

50.00%

时间&空间限制

  • Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others)
  • 描述

    At DUT, the Dreamland University of Technology, all students have personal id, numbers with six or seven digits. But they're not just any numbers. Only those that have a checksum with a zero as last digit can be valid ids.
    Problem
    Here's how to compute the checksum of an id number. Multiply the digits from back to front (!) with repeating factors 9, 3, 7. Then simply add the products. Example:
    id number :  1  3  9  0  2  7  2
    factors   :  9  7  3  9  7  3  9
    products  :  9 21 27  0 14 21 18

    Here the checksum is 9+21+27+0+14+21+18 = 110. The last digit is zero, so the id is valid. Sometimes students have very bad handwriting and the teaching assistents have a hard time identifying the id’s. You're asked to help in special cases, where exactly one digit is unreadable. In that case, the missing digit can be computed (there's always exactly one correct digit, thanks to 9, 3 and 7 being relatively prime to 10). Note that the students always begin concentrated and thus the first digit will always be readable (and not zero).

    输入

    The first line contains the number of scenarios. Each scenario is a single line that contains an id number with one digit replaced by a question mark and with six or seven digits length.

    输出

    Description

    At DUT, the Dreamland University of Technology, all students have personal id, numbers with six or seven digits. But they're not just any numbers. Only those that have a checksum with a zero as last digit can be valid ids.
    Problem
    Here's how to compute the checksum of an id number. Multiply the digits from back to front (!) with repeating factors 9, 3, 7. Then simply add the products. Example:
    id number :  1  3  9  0  2  7  2
    factors   :  9  7  3  9  7  3  9
    products  :  9 21 27  0 14 21 18

    Here the checksum is 9+21+27+0+14+21+18 = 110. The last digit is zero, so the id is valid. Sometimes students have very bad handwriting and the teaching assistents have a hard time identifying the id’s. You're asked to help in special cases, where exactly one digit is unreadable. In that case, the missing digit can be computed (there's always exactly one correct digit, thanks to 9, 3 and 7 being relatively prime to 10). Note that the students always begin concentrated and thus the first digit will always be readable (and not zero).

    Input
    The first line contains the number of scenarios. Each scenario is a single line that contains an id number with one digit replaced by a question mark and with six or seven digits length.
    Output
    The output for every scenario begins with a line containing "Scenario #i:", where i is the number of the scenario starting at 1. Then print a single line containing the correct id number. Terminate the output for the scenario with a blank line.
    Sample Input
    4
    13?0272
    3?5678
    345?78
    314?592
    Sample Output
    Scenario #1:
    1390272

    Scenario #2:
    335678

    Scenario #3:
    345778

    Scenario #4:
    3146592
    Hint

    Huge input and output, scanf and printf are recommended.

    Source

    样例输入

    4
    13?0272
    3?5678
    345?78
    314?592

    样例输出

    Scenario #1:
    1390272

    Scenario #2:
    335678

    Scenario #3:
    345778

    Scenario #4:
    3146592

    提示

    Huge input and output, scanf and printf are recommended.


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部