We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,473 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

run time error

#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

2
Contributors
7
Replies
4 Hours
Discussion Span
9 Months Ago
Last Updated
8
Views
shanki himanshu
Junior Poster
130 posts since Dec 2010
Reputation Points: 37
Solved Threads: 1
Skill Endorsements: 0

What compiler and OS are you using? What's the runtime error?

deceptikon
Challenge Accepted
Administrator
3,457 posts since Jan 2012
Reputation Points: 822
Solved Threads: 474
Skill Endorsements: 57

SIGXFSZ ..
i tried it on ideone.com

here the link: http://ideone.com/dyG4V

shanki himanshu
Junior Poster
130 posts since Dec 2010
Reputation Points: 37
Solved Threads: 1
Skill Endorsements: 0

Are you redirecting output to a file? SIGXFSZ is the signal raised when a file exceeds its size limitation.

deceptikon
Challenge Accepted
Administrator
3,457 posts since Jan 2012
Reputation Points: 822
Solved Threads: 474
Skill Endorsements: 57

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.

shanki himanshu
Junior Poster
130 posts since Dec 2010
Reputation Points: 37
Solved Threads: 1
Skill Endorsements: 0

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.

deceptikon
Challenge Accepted
Administrator
3,457 posts since Jan 2012
Reputation Points: 822
Solved Threads: 474
Skill Endorsements: 57

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

shanki himanshu
Junior Poster
130 posts since Dec 2010
Reputation Points: 37
Solved Threads: 1
Skill Endorsements: 0

scanf works.
but how to do it in c++?

shanki himanshu
Junior Poster
130 posts since Dec 2010
Reputation Points: 37
Solved Threads: 1
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0803 seconds using 2.67MB