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:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.5, RUBY, SCALA, SCM chicken, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC|
Fetching successful submissions
If you are still having problems, see a sample solution here.