Files
PAT/source/html/b1031.html
T

30 lines
2.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
查验身份证
<div class="ques-view"><p>一个合法的身份证号码由17位地区、日期编号和顺序编号加1位校验码组成。校验码的计算规则如下:</p>
<p>首先对前17位数字加权求和,权重分配为:{7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};然后将计算的和对11取模得到值<code>Z</code>;最后按照以下关系对应<code>Z</code>值与校验码<code>M</code>的值:</p>
<pre><code>Z:0 1 2 3 4 5 6 7 8 9 10
M:1 0 X 9 8 7 6 5 4 3 2
</code></pre><p>现在给定一些身份证号码,请你验证校验码的有效性,并输出有问题的号码。</p>
<h3 id="-">输入格式:</h3>
<p>输入第一行给出正整数<span class="katex"><span class="katex-mathml"><math><mrow><mi>N</mi></mrow>N</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.10903em;">N</span></span></span></span>(<span class="katex"><span class="katex-mathml"><math><mrow><mo>≤</mo><mn>1</mn><mn>0</mn><mn>0</mn></mrow>\le 100</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.64444em;"></span><span class="strut bottom" style="height:0.78041em;vertical-align:-0.13597em;"></span><span class="base textstyle uncramped"><span class="mrel">≤</span><span class="mord mathrm">1</span><span class="mord mathrm">0</span><span class="mord mathrm">0</span></span></span></span>)是输入的身份证号码的个数。随后<span class="katex"><span class="katex-mathml"><math><mrow><mi>N</mi></mrow>N</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.10903em;">N</span></span></span></span>行,每行给出1个18位身份证号码。</p>
<h3 id="-">输出格式:</h3>
<p>按照输入的顺序每行输出1个有问题的身份证号码。这里并不检验前17位是否合理,只检查前17位是否全为数字且最后1位校验码计算准确。如果所有号码都正常,则输出<code>All passed</code>。</p>
<h3 id="-1-">输入样例1:</h3>
<pre><code class="lang-in">4
320124198808240056
12010X198901011234
110108196711301866
37070419881216001X
</code></pre>
<h3 id="-1-">输出样例1:</h3>
<pre><code class="lang-out">12010X198901011234
110108196711301866
37070419881216001X
</code></pre>
<h3 id="-2-">输入样例2:</h3>
<pre><code>2
320124198808240056
110108196711301862
</code></pre><h3 id="-2-">输出样例2:</h3>
<pre><code>All passed
</code></pre><p><strong>鸣谢阜阳师范学院范建中老师补充数据</strong></p>
</div>