my code is at:https://ide.codingblocks.com/s/100703
I am getting TLE.
Prateek Loves Candy 1
@gyrsh hey vibhor your implementation is not right please go and see the Optimisations in Prime Sieve in your course content.and try to optimise your code further.
I’ve optimize the code,but still getting TLE,same code link as above.
@gyrsh hey vibhor next time please do tag with
@ followed by name of a particular ta’s name if you don’t mention it like similar manner as I suggest you we will not get any notification from your side and doubt will be unresolved
hey this approach may work for deepak and prime
but prateek love candy required some more modification
do design your main function like this
int main()
{
ll n=10000005;
ll ar[n]={0};
prime(ar,n);
vectorv;
for(ll i=0;i<=n;i++)
{
if(ar[i]==1)
{
v.push_back(i);
}
}
int t;
cin>>t;
while(t--)
{
int key;
cin>>key;
cout<<v[key-1]<<endl;
}
}
and in the calling function
pass the array ar and n
and use some part from your code
the function value now design like that
remove t from your function
and loop will go upto n as we are passing from main function remove prime vector too.