JOIN
Get Time

   Problem Statement  

 Problem Statement for PrimePolynom

Problem Statement

    

A prime number is an integer greater than 1 that has no positive divisors other than 1 and itself. The first prime numbers are 2, 3, 5, 7, 11, 13, 17, ...

It is known that no non-constant polynomial function P(n) exists that evaluates to a prime number for all integers n. But there are some famous quadratic polynomials that are prime for all non-negative integers less than M (M depends on the polynomial).

You will be given ints A, B and C. Your method should return the smallest non-negative integer M such that A*M2 + B*M + C is not a prime number.

 

Definition

    
Class:PrimePolynom
Method:reveal
Parameters:int, int, int
Returns:int
Method signature:int reveal(int A, int B, int C)
(be sure your method is public)
    
 

Constraints

-A will be between 1 and 10000, inclusive.
-B will be between -10000 and 10000, inclusive.
-C will be between -10000 and 10000, inclusive.
 

Examples

0)
    
1
-1
41
Returns: 41
This is one of the famous polynomials.
1)
    
1
1
41
Returns: 40
2)
    
1
1
-13
Returns: 0
No negative numbers are prime.
3)
    
1
-15
97
Returns: 48
4)
    
1
-79
1601
Returns: 80
The largest possible answer.

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.

This problem was used for:
       Single Round Match 259 Round 1 - Division II, Level Two