当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2498:StuPId

题目描述
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).
输入解释
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.
输出解释
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.
输入样例
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.

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2498

最后修改于 2020-10-29T06:34:07+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000 65536