Codey and Peaks
https://www.hackerrank.com/contests/codenection-2024-preliminary-round-open-category/challenges/cn24-15
Question
Codey is about to explore the legendary Code Mountain, a famous destination for touching grass.
Code Mountain is a one-dimensional mountain made up of n
units, which can be represented by an array a
of length n
, where is the height of the -th unit. What's special about this mountain is that it is known to have only two peaks. Formally, there are only two values of (where ) such that .
Unfortunately, Codey only knows the heights of the two peaks, while the heights of the remaining units are denoted by . Help Codey figure out how many possible combinations of the array a
exist modulo , so that he can better prepare for the exploration.
You can assure the max height for each unit is .
Input Format
The first line contains an integer n
, which represents the number of units in the Code Mountain.
The second line contains n
integers, each representing the height of the -th unit.
Constraints
Only two , where
Output Format
Output the total number of combinations of the array a
that fulfill the conditions modulo .
Sample Inputs:
Last updated