long run time

I HAVE BEEN TRYING OUT PROJECTEULER.NET PROBLEMS
I AM HAVING DEV C++ ON MY 64 BIT SYSTEM
I AM A ROOKIE IN PROGRAMMING BUT MY ALGORITHMS ARE CORRECT
WHAT HAPPENS IS THAT THE EXE FILE GENERATED FOR SOLVING THE PROBLEMS DOESNT PRODUCE ANY RESULT AT ALL ITS JUST THE BLANK BLACK SCREEN. DUE TO LARGE INPUTS WHICH I THINK SHOULD BE FAIRLY COMPUTABLE
Can u suggest some method to optimize code

for example #include<iostream>
using namespace std;
int main ()
{for(long g=50;g<1E7;++g)
{int d=2;
long p=((g*(g+1))/2);
for(long c=2;c<p;++c)
if(!(p%c))
++d;
if (d>=499)
{cout<<g<<endl<<d;int a;cin>>a;
}
}return 0;
}


this program gives no output
what all could i do to get proficient in programming
mayb i could use gmp library but i m unable to install it
Please use code tags (look for the <> button)to make your code more readable. I say "more" readable because even with code tags your code is virtually unreadable and you've supplied just about no information that would help us help you.

For instance, it might've been nice to know which problem you're working on, just as it might've been nice for your code to have variables with meaningful names.

I'm reasonably certain you're working on problem 12. You need to think in terms of optimizing the algorithm, and there is plenty of room to do it.

For instance, is there a way you could reuse the results of previous tests to speed up current ones? Is there some way you could narrow down the range of the numbers you're testing? (Hint: What is the smallest number with 500 unique divisors?) Should you be using a different algorithm altogether?

Some useful info:
http://mathschallenge.net/index.php?section=faq&ref=number/number_of_divisors

If you're going to be working on Euler problems, google is going to be your best friend.
Last edited on
Topic archived. No new replies allowed.