UNITGCD - Editorial

Seperating all prime numbers to first day ,
This was my approach

just add
#define endl “\n”
and your code will be accepted
endl slows the performance because it unnecessarily flush, and in this case you are using it n/2 times that significantly impacts the time.

i have try same approch but it shows TLE error CodeChef: Practical coding for everyone can anyone help please

@mohitz_007 I am getting correct output for n=15 as well, you can check for yourself. Still can’t figure out where am i going wrong. I need to figure this out! please help anyone.

Have u tried \ n instead of endl

i have written \n but it shows error

yes , now solution is accepted.

Thanks for the link

Here is the commented code for the solution.

no it is not accepted

My solution gets Runtime Error RE (SIGXFSZ). I found this error relates to printing more output lines. Here’s my solution. Could someone help?.

1 Like

Thanks it worked for me too.

1 Like

UNITGCD

I can’t seem to figure out where my program is failing , tried it multiple of ways , used ‘\n’ instead of endl , gives correct output but it only passes 1 test case out of 3 . Can anyone help me ? : (

For base case n=1 your code gives WA. For n=1 you have to print:
1
1 1
But you are printing
1
1

@cohlem

Thanks Man . Appreciate you effort : ) @ayushomi007

1 Like

Can someone help me with this one??

use \n instead of endl

I attempted it almost 10 times out of 10 times 8 times I got TLE. I know the logic behind this problem but always shows tle. What should I do in this case?
Plss help and support :pray::pray:

Here’s my code-: CodeChef: Practical coding for everyone

Use \n instead of endl.

Go through this: std::endl vs n in C++ - GeeksforGeeks

1 Like

To all who got TLE change cout<<endl ---- > cout<< ‘\n’
to get rid of this i make a macro

#define endl '\n'

so that wherever I use cout<<endl it will automatically replaced by cout<< ‘\n’