For simple no.s code is working but for large no.s code is not working showing timelimit
My code is :
Large no.s not working
Hello @Ramitgoel,
The array a[] of your code is causing TLE.
Reason:
for(i=1;i<=n;i++) { a[i-1]=i; }
Try to implement this approach with using any array.
Let me know, if you face any issue.
Hope, this would help.
Give a like if you are satisfied.
yes i tried to change it to n/2 as for any no. its square root is less than and equal to half of that no. so i will take the array till n/k and if k=1 i will imply print n
https://ide.codingblocks.com/s/146488
Then also its showing runtime error and timelimit
Hello @Ramitgoel,
The constraint on N is:
1<=N<=10^15
Iterating it to N/2 i.e. 10^15/2=5*10^14.
It will cause TLE too.
You can refer to the following code:
Let me know, if you do not understand something.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.