Files
PAT/source/html/b1067.html
T

34 lines
2.0 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>当你试图登录某个系统却忘了密码时,系统一般只会允许你尝试有限多次,当超出允许次数时,账号就会被锁死。本题就请你实现这个小功能。</p>
<h3 id="-">输入格式:</h3>
<p>输入在第一行给出一个密码(长度不超过 20 的、不包含空格、Tab、回车的非空字符串)和一个正整数 N(<span class="katex"><span class="katex-mathml"><math><mrow><mo>≤</mo></mrow>\le</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.63597em;"></span><span class="strut bottom" style="height:0.7719400000000001em;vertical-align:-0.13597em;"></span><span class="base textstyle uncramped"><span class="mrel">≤</span></span></span></span> 10),分别是正确的密码和系统允许尝试的次数。随后每行给出一个以回车结束的非空字符串,是用户尝试输入的密码。输入保证至少有一次尝试。当读到一行只有单个 # 字符时,输入结束,并且这一行不是用户的输入。</p>
<h3 id="-">输出格式:</h3>
<p>对用户的每个输入,如果是正确的密码且尝试次数不超过 N,则在一行中输出 <code>Welcome in</code>,并结束程序;如果是错误的,则在一行中按格式输出 <code>Wrong password: 用户输入的错误密码</code>;当错误尝试达到 N 次时,再输出一行 <code>Account locked</code>,并结束程序。</p>
<h3 id="-1-">输入样例 1:</h3>
<pre><code class="lang-in">Correct%pw 3
correct%pw
Correct@PW
whatisthepassword!
Correct%pw
#
</code></pre>
<h3 id="-1-">输出样例 1:</h3>
<pre><code class="lang-out">Wrong password: correct%pw
Wrong password: Correct@PW
Wrong password: whatisthepassword!
Account locked
</code></pre>
<h3 id="-2-">输入样例 2:</h3>
<pre><code class="lang-in">cool@gplt 3
coolman@gplt
coollady@gplt
cool@gplt
try again
#
</code></pre>
<h3 id="-2-">输出样例 2:</h3>
<pre><code class="lang-out">Wrong password: coolman@gplt
Wrong password: coollady@gplt
Welcome in
</code></pre>
</div>