Wrong Answer for 4 test cases

Can anyone please tell me why is it giving wrong answer!
link for the code:

@ria_jhaX5P
Please see this code

But what is wrong with my code?

@ria_jhaX5P
2 major issues are
First you’re calculating primes for no reason
Second you are using int instead of long long

I request you to see the code I sent
That is the correct approach

Why you have multiplied only 500000004 with each element of the vector?

@ria_jhaX5P
We had to divide vec[i] by 2
But since we are using modulo we need to do modulo division which involves multiplication with modulo inverse of mod
Modulo inverse of 2 is 500000004 with respect to 10^9+7

1 Like