mirror of
https://github.com/xlucn/PAT.git
synced 2026-11-04 00:38:13 +08:00
16 lines
1.6 KiB
HTML
16 lines
1.6 KiB
HTML
是否存在相等的差
|
||
<div class="ques-view"><p>给定 N 张卡片,正面分别写上 1、2、……、N,然后全部翻面,洗牌,在背面分别写上 1、2、……、N。将每张牌的正反两面数字相减(大减小),得到 N 个非负差值,其中是否存在相等的差?</p>
|
||
<h3 id="-">输入格式:</h3>
|
||
<p>输入第一行给出一个正整数 N(2 <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> 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 000),随后一行给出 1 到 N 的一个洗牌后的排列,第 i 个数表示正面写了 i 的那张卡片背面的数字。</p>
|
||
<h3 id="-">输出格式:</h3>
|
||
<p>按照“差值 重复次数”的格式从大到小输出重复的差值及其重复的次数,每行输出一个结果。</p>
|
||
<h3 id="-">输入样例:</h3>
|
||
<pre><code class="lang-in">8
|
||
3 5 8 6 2 1 4 7
|
||
</code></pre>
|
||
<h3 id="-">输出样例:</h3>
|
||
<pre><code class="lang-out">5 2
|
||
3 3
|
||
2 2
|
||
</code></pre>
|
||
</div> |