Filling stones
93% Success2445 Attempts10 Points1s Time Limit256MB Memory1024 KB Max Code

You are given an integer \(N\). You have total \(2N\) stones numbered from 1 to \(2N\). You have initially two empty arrays of size \(N\) each. You have to fill both the arrays utilizing all the \(2N\) stones and using each stone in only one array.

Let us define the beauty of an array as the difference between the sum of elements at odd positions and the sum of elements at even positions.

The beauty of an array is \(|S1-S2|\) where:

  • \(S1 = ∑Ai1\) where \(Ai1\) are the elements positioned at an odd position in an array
  • \(S2 = ∑Ai2\) where \(Ai2\) are the elements positioned at an even position in an array

Your task is to arrange the stones in both arrays such that the product of the beauty of both arrays is as minimum as possible.

Input format

A single integer representing \(N\) (\(0)

Output format

Print that minimum possible product of the beauty of those two arrays.

Examples
Input
5
Output
0
Explanation

Since N = 5, we have stones 1,2,3,4,5,6,7,8,9,10.

We can arrange the stones in this way

Array 1: [1,2,3,7,5] 
Here, the beauty = |(1+3+5)-(2+7)| = |9-9| = 0
So beauty = 0
 
Array 2 : [6,4,8,9,10] : 
Here, the beauty = |(6+8+10)-(4+9)| = |24-13| = 11
So beauty = 11

So that the Product is minimum possible. 
Product = 0*11 = 0

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading Editor...
Results