TopCoder problem "InequalityChecker" used in SRM 230 (Division II Level One)



Problem Statement

    Using mathematical induction it is possible to prove the following inequality when n>1:
	s = 13 + 23 + ... + (n-1)3 < n4/4 < 13 + 23 + ... + n3 = S
Given n return (S+s)/2 - n4/4 as a int[] with 2 elements. Elements 0 and 1 denote the numerator and denominator of the return value, respectively, when written in least terms (reduced).
 

Definition

    
Class:InequalityChecker
Method:getDifferences
Parameters:int
Returns:int[]
Method signature:int[] getDifferences(int n)
(be sure your method is public)
    
 

Constraints

-n will be between 2 and 100 inclusive.
 

Examples

0)
    
2
Returns: { 1,  1 }
We have
s = 1^3 = 1
S = 1^3 + 2^3 = 9
(S+s)/2 = (1+9)/2 = 5
n^4/4 = 16/4 = 4 
Since 5-4 = 1, we return the fraction 1/1.
1)
    
3
Returns: { 9,  4 }
We have
s = 1^3 + 2^3 = 9
S = 1^3 + 2^3 + 3^3 = 36
(S+s)/2 = 45/2
n^4/4 = 81/4
We return the fraction 9/4.
2)
    
100
Returns: { 2500,  1 }
Largest case.

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=3560

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=6519&pm=3560

Writer:

AdminBrett

Testers:

PabloGilberto , lbackstrom , Olexiy

Problem categories:

Brute Force