补作业 1

                                                               STUPLD

Background:
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.

翻译:

                                                        愚蠢的

题目背景:
在DUT,梦境科技大学,所有学生都有个人身份证,号码有六或七位数字。但它们不只是任何数字。只有最后一个数字为零的校验和可以是有效的ID。
问题
下面是如何计算id号的校验和。将数字从后到前相乘(!)重复因子9,3,7。然后简单地添加产品。

例子:
身份证号码:1 3 9 0 2 7 2

因素:9 7 3 9 7 3 9
产品:92127014218


这里的校验和是9+21+27+0+14+21+18=110。最后一个数字是零,所以id是有效的。有时学生的笔迹很糟糕,助教很难识别身份证。在特殊情况下,你需要帮助,因为只有一个数字是不可读的。在这种情况下,可以计算缺失的数字(由于9、3和7是相对10的素数,所以总是有一个正确的数字)。注意,学生们总是集中注意力,因此第一个数字总是可读的(而不是零)。


输入:


第一行包含场景的数量。每个场景都是一行,其中包含一个id号,其中一个数字由问号替换,长度为6或7位。

输出:
每个场景的输出都以一行开头,其中包含“场景#i:”,其中i是从1开始的场景数。然后打印一行包含正确的id号。使用空行终止场景的输出。

八根手指打字挺不习惯的  害   希望可以快点好起来
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值