When i is one, the questions is "how many people tried the first question" and the answer is k^3.
No, the answer is 39 which 3^1 + 3^2 + 3^3
I disagree.
27 people tried the first question. Not 39.
27 people tried the first question.
9 tried the second.
3 tried the third question.
39 is the number of people who tried the first question, plus the the number of people who tried the second question, plus the number of people who tried the third question.
It seems to me that you keep answering the wrong question. If 27 people answer the first question, how many people answer the first question? 27. I don't know where you get 39 for that answer.
It says " task is to determine the sum of total number of players who has attempted ith question for all (1<=i<=N)".
So first answer it for i=1
Then answer it for i=2
Then answer it for i=3
Then answer it for i=4
What else could "for all i" mean?
This question is so badly written. Even the sample answer make no sense; the sample answer doesn't give the sum for all i from one to N. Was the question originally written in English or has it been translated?
The idea is that in order to ensure that the last answer is answered correctly you need one person per possible answer. That's K people. Therefore you would need K^2 (using ^ for exponentiation) for the second-last question to ensure that K are left for the last question. Therefore you would need K^3 for the third-last question, etc.
So for the given example the answer is 3^3 + 3^2 + 3^1 = 39.
So I agree with the OP's original interpretation of the problem. You need to calculate the sum of a geometric series:
[ K * (K^N - 1) / (K - 1) ] mod 1000000007
Take N = 17, K = 13. Using bc, the answer is:
$ bc<<<'(13 * (13^17 - 1) / (13 - 1))) % 1000000007'
64129164
But the following program gets the wrong answer for N=17, K=13 because the division by K - 1, which would go evenly into the power calculated without the modulus, doesn't go evenly into the power calculated with the modulus.
@Repeater, just so you know, it wasn't me who "reported" your post. I have no idea why someone would do that. The report button seems mostly meaningless, anyway. Obviously someone is screwing around with it.
As for whether the question was written in English or was translated, I suspect that it was in fact written in English, but by someone whose first language is NOT English.