#include<iostream>
#include<math.h>

using namespace std;

int main()
{
long int t,n;
cin>>t;
while(t--)

{
cout<<"abc";
}
return 0;
}

i am getting run time error for t>10000.
how to solve it. range of t>1000000

Edited 4 Years Ago by shanki himanshu

actually there is a question on a website in which number of test cases are <1000000
i am submitting there. the site is giving me time limit exceeded.
my code complexity is O(1). so i tried it on ideone which gives me run time error.

i am submitting there. the site is giving me time limit exceeded.

Okay, that's completely different. Obviously if you're writing to cout over 10,000 times then it's going to take a while. That's the problem, and the root cause is that your code is too slow due to the overhead of output.

my code complexity is O(1).

No, your code complexity is O(t).

so i tried it on ideone which gives me run time error.

It's not unreasonable to assume that Ideone has stringent limits on things like this, so I'm not surprised at all that you got a SIGXFSZ error. Use a real compiler on your local machine and that error will vanish.

in my code i have to calculate just sqrt of input.
i tried scanf but it gives TLE too. so what should i do?

This question has already been answered. Start a new discussion instead.