TopCoder problem "FoxMakingDice" used in Member SRM 491 (Division I Level One)



Problem Statement

    

Fox Jiro likes dice. He wants to make his own dice. Each die he wants to make is a cube. Each of the 6 faces has an integer between 1 and N, inclusive. No two faces have same number. Also the following condition must be satisfied: for all faces, the sum of the numbers on opposite faces must be equal and the sum must be greater than or equal to K.



He realized that there are many ways to make such dice. He wants to know how many ways there are. Please help Jiro to make a program that is given two integers N and K and returns the number of different dice satisfying the condition mentioned above.



Two dice are considered the same if you can rotate one to form the other.

 

Definition

    
Class:FoxMakingDice
Method:theCount
Parameters:int, int
Returns:long
Method signature:long theCount(int N, int K)
(be sure your method is public)
    
 

Notes

-The answer will always fit in a signed 64-bit integer.
 

Constraints

-N will be between 1 and 1,000, inclusive.
-K will be between 1 and 2,000, inclusive.
 

Examples

0)
    
6
7
Returns: 2
You can make normal dice. There are two ways to arrange the numbers.
1)
    
5
7
Returns: 0
You cannot make 6 sided dice with 5 numbers.
2)
    
1000
1
Returns: 20625666000
3)
    
456
123
Returns: 879075732
4)
    
913
1014
Returns: 4506149340

Problem url:

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

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=14244&pm=11234

Writer:

wrong

Testers:

Rustyoldman , ivan_metelsky , Mimino , rng_58

Problem categories:

Simple Math, Simple Search, Iteration