https://hack.codingblocks.com/contests/c/512/63
https://ide.codingblocks.com/s/34264
Test Case Number | Result |
---|---|
#1 | Passed |
#2 | wrong-answer |
#3 | Time Limit Exceeded |
https://hack.codingblocks.com/contests/c/512/63
https://ide.codingblocks.com/s/34264
Test Case Number | Result |
---|---|
#1 | Passed |
#2 | wrong-answer |
#3 | Time Limit Exceeded |
https://ide.codingblocks.com/s/34312
I have corrected your code and now it passes the case 1 and 2.
You are getting TLE in case 3 because complexity of your code is huge O(T10000001000).
HINT: Try optimising by using sieve and pre-computation.
Here is my solution for your reference.
https://ide.codingblocks.com/s/34313