mirror of
https://github.com/xlucn/PAT.git
synced 2026-11-04 00:38:13 +08:00
24 lines
4.0 KiB
HTML
24 lines
4.0 KiB
HTML
Google Recruitment
|
|
<div class="ques-view"><p>In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The content is super-simple, a URL consisting of the first 10-digit prime found in consecutive digits of the natural constant <span class="katex"><span class="katex-mathml"><math><mrow><mi>e</mi></mrow>e</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.43056em;"></span><span class="strut bottom" style="height:0.43056em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit">e</span></span></span></span>. The person who could find this prime number could go to the next step in Google's hiring process by visiting this website.</p>
|
|
<p><img alt="prime.jpg" src="https://images.ptausercontent.com/57148679-d574-4f49-b048-775c6c07791c.jpg"/></p>
|
|
<p>The natural constant <span class="katex"><span class="katex-mathml"><math><mrow><mi>e</mi></mrow>e</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.43056em;"></span><span class="strut bottom" style="height:0.43056em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit">e</span></span></span></span> is a well known transcendental number(超越数). The first several digits are: <span class="katex"><span class="katex-mathml"><math><mrow><mi>e</mi></mrow>e</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.43056em;"></span><span class="strut bottom" style="height:0.43056em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit">e</span></span></span></span> = 2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642<strong>7427466391</strong>932003059921... where the 10 digits in bold are the answer to Google's question.</p>
|
|
<p>Now you are asked to solve a more general problem: find the first K-digit prime in consecutive digits of any given L-digit number.</p>
|
|
<h3 id="input-specification-">Input Specification:</h3>
|
|
<p>Each input file contains one test case. Each case first gives in a line two positive integers: L (<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> 1,000) and K (<span class="katex"><span class="katex-mathml"><math><mrow><mo><</mo></mrow><</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.5391em;"></span><span class="strut bottom" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="base textstyle uncramped"><span class="mrel"><</span></span></span></span> 10), which are the numbers of digits of the given number and the prime to be found, respectively. Then the L-digit number N is given in the next line.</p>
|
|
<h3 id="output-specification-">Output Specification:</h3>
|
|
<p>For each test case, print in a line the first K-digit prime in consecutive digits of N. If such a number does not exist, output <code>404</code> instead. Note: the leading zeroes must also be counted as part of the K digits. For example, to find the 4-digit prime in 200236, 0023 is a solution. However the first digit 2 must not be treated as a solution 0002 since the leading zeroes are not in the original number.</p>
|
|
<h3 id="sample-input-1-">Sample Input 1:</h3>
|
|
<pre><code class="lang-in">20 5
|
|
23654987725541023819
|
|
</code></pre>
|
|
<h3 id="sample-output-1-">Sample Output 1:</h3>
|
|
<pre><code class="lang-out">49877
|
|
</code></pre>
|
|
<h3 id="sample-input-2-">Sample Input 2:</h3>
|
|
<pre><code class="lang-in">10 3
|
|
2468024680
|
|
</code></pre>
|
|
<h3 id="sample-output-2-">Sample Output 2:</h3>
|
|
<pre><code class="lang-out">404
|
|
</code></pre>
|
|
</div> |