All submissions for this problem are available.
A game is played on an array whose ith value is denoted by arr[i]. The game is defined as follows:
One move is defined as removing any two numbers from the array, 'a' and 'b', and adding to the end of array a new number c such that c = a + b + (a * b).
This is continued alternately between the players until only one number remains, res. The result of the game is res + 1.
We compute the exponent of a number m in the factorization of this result. If this exponent is non-prime, player1 wins otherwise player2 wins.
Srijan and Ankit are going to play this game and because it is Srijan's birthday, he gets to play first. Also, Srijan can choose a non-empty subarray of the given array arr. The game will be played on only this chosen subarray.
Srijan chooses the subarray randomly.
If Srijan has lost despite these advantages, what is the expected value of the exponent of m at the end of game?
The first line contains two space-separated integers n(the length of the array) and m. The next line contains n space-separated integers, representing the array.
Output a single value, the expected value of the exponent of m, with a maximum error of 10-6.
1 ≤ n ≤ 105
1 ≤ arr[i] ≤ 1018
1 ≤ m ≤ 100
m is guaranteed to be a prime number.
Input: 5 7 2 5 3 9 4 Output: 0.0
Input: 2 3 49 50 Output: 0.0
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.