Hangdian 2710 (water question)

Source: Internet
Author: User
Max Factor
<span size="+0"><strong><span style="font-family:Arial;font-size:12px;color:green;FONT-WEIGHT: bold">Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3693    Accepted Submission(s): 1181</span></strong></span>
Problem Description
To improve the organization of his farm, Farmer John labels each of his N (1 <= N <= 5,000) cows with a distinct serial number in the range 1..20,000. Unfortunately, he is unaware that the cows interpret some serial numbers as better than others. In particular, a cow whose serial number has the highest prime factor enjoys the highest social standing among all the other cows.(Recall that a prime number is just a number that has no divisors except for 1 and itself. The number 7 is prime while the number 6, being divisible by 2 and 3, is not).Given a set of N (1 <= N <= 5,000) serial numbers in the range 1..20,000, determine the one that has the largest prime factor.
<span style="font-size:14px;"></span>
* Line 1: A single integer, N* Lines 2..N+1: The serial numbers to be tested, one per line
<span style="font-size:14px;"></span>
* Line 1: The integer with the largest prime factor. If there are more than one, output the one that appears earliest in the input file.
<span style="font-size:14px;"></span>
Sample Input
<span style="font-size:14px;"></span>
Sample Output
<span style="font-size:14px;"></span>
USACO 2005 October Bronze 
<Span style = "font-size: 14px;"> A water question is filtered out by prime numbers or directly, but it is a waste of afternoon due to a small detail. </Span>
<Span style = "font-size: 14px;"> the code is as follows: </span>
<Span style = "font-size: 14px;" >#include <stdio. h> int prime (int n) {int I; for (I = 2; I <n-1; I ++) if (N % I = 0) return 0; return 1;} int main () {int I, j, n, m, Max, max1; while (~ Scanf ("% d", & N) {max = 0; for (I = 0; I <n; I ++) {scanf ("% d ", & M); For (j = m; j> 0; j --) {If (M % J = 0 & prime (j )) // The Code will not change the order of the two items, and it will time out. Do not pay attention when doing so {If (j> = max) max = J, max1 = m; break ;}} printf ("% d \ n", max1) ;}return 0 ;}</span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.