Mike and Matrix Game

4.8

4 votes
Combinatorics, Medium, Probability, Statistics
Problem

Mike and Harvey are back together! To celebrate this special occasion, they decided to play a unique game. So, this is how it goes :

Mike gives Harvey an N×N grid A containing integers and 2 integers K and X. Now, Harvey begins the game by selecting K distinct rows among the N rows. He will then add the integer X to all elements of the selected rows.

Mike will then write N integers on a piece of paper, where the ith integer denotes the maximum integer present in the ith column. He then tells Harvey the sum of all integers written on that piece of paper. Let's call this number Mike tells Harvey as Z

This is where your part comes in. Considering that Harvey selects each distinct tuple of K rows with equal probability, you are to find the Expected Value of Z. Can you do this ?

Your answer will be considered correct if the absolute OR relative error between your answer and the jury's answer is 109 . More formally, let your answer be a and the jury's answer be b. Your solution will be considered correct if |ab|max(1,b)109

Input Format :

The first line contains 3 space separated integers N,K and X respectively.

Each of the next N lines contains N space separated integers, where the jth integer on the ith line denotes A[i][j].

Output Format :

For each test case, print a single real number denoting the answer to the problem.

Constraints :

2N1000

1KN

0A[i],X106

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

.

Editor Image

?