see this http://www.daniweb.com/forums/thread78223.html
particularly point 4.
a+=b;
is equivalent to
a=a+b;
Sorry Diophantine equations are beyond me. Perhaps you should try a math forum for more advice, then come here for help with the coding.
I think jonsca is correct, the answer seems too large to simply iterate through(be a little easy if so). I believe that there will be a clever mathematical shortcut.
It's not Euler but it's their kind of problem.
would unsigned long long int(instead of int) suffice?
it can be found on some very old nokia phones.
I presumed addition of the two without noticing they were of different size:$
Disregard my first post.
Am i correct in thinking you have been given an assignment in which you need to create a large array(and you are presumably using the same compiler as your teacher or whoever gave you this task) and you can't use pointers or vectors?
Then it seems like an unusual assignment.:confused:
can you use vectors?
int size = 85020;
int* array = new int[size];
//..utilize array
delete [] array; //release memory for later use
don't know of a clever way but using 2 arrays would work. read into array1 then into array2 then have a loop which adds the value in each part of array2 to each part of array1 then output array1.
answer immediately please
strange phrase. what seems to be an order followed by a plea????
You keep pencils in a beerstein? Germany and myself are appalled.
Static at approx 110 dB. Listening to the universe waiting for someone to say something.
Drill a hole on the bottom of each bucket and cover with the aforementioned tape. When u need to "flush" go outside and remove tape(spinning round will aid the process). Hope this helps.:)
ok
step 3.5 - If dying GOTO step 5
step 5 - Seek medical assistance.
This patch should clear things up.
p.s how do you spell dying(and not in the colour sense)?
am i right?
"dieing" that can't be right surely.
@ardav tape, 2 buckets and a willingness to stand bent over for a prolonged period.(if not tape string may work)
dropped it because it was harder than first class
is not entirely different from
'harder than I expected it to be'
neither is it a good reason.
Reading your post i feel the need to go out and buy some form of upper garment related to a sporting team. Can you help me?
:icon_rolleyes:
Give that you quit something because it wasn't easy, then it probably doesn't matter what you choose.
1,132,345,679 exactly at time of posting.
P.S my wife's computer just blew up so subtract 1.
Franka Potente.
Then you should mark the thread as solved.
cure
step 1 - Find pint glass.
step 2 - Fill with beer.
step 3 - Drink contents of glass.
step 4 - GOTO step 2.
this should fix it.
what do you mean "it is buyer uplift only." ?
come and get it.
Chuckie Egg, without doubt.
no problem you can have my old one but it is buyer uplift only.
You may recieve more help if you clearly state your problem. i.e what do you expect your program to do and what is it doing wrong.
P.S USE CODE TAGS.
i think you need to seed rand.
something like
srand(time(NULL));
In isprime can you not stop the search once the value in the vector is larger than the check value you send it?
a possible speed up would be to generate the primes in a seperate program and output them to a file, then read them into your program into a vector and check that. it would mean only generating them once.
thanks for the reply.
still very new at this so hope my questions don't seem too dumb.
thanks. so do i need to #include <ctime> to use clock()?
ok. any explanation why it seems to work?
very limited knowledge of this but this using ctime appears to give a rough time the code took to run.
double time=clock();
//program
cout<<clock()-time<<" ms"; or cout<<(clock()-time)/1000<<" seconds.";
This may work.
for(i=0;i<DetectedFaces.size();i++)
{
temp.push_back(DetectFaces[i]);
}
With 2 nested loops(pure brute force) and a simple prime checker mine's works in about 1s but i'm too new to this to suggest where the slow down is.
Read the forum it's usually full of good tips.
As you have the generation of primes done you should take a look at the most recent problem(315). No maths but a nice programming exercise.
try google for isupper toupper etc.
never mind beat to the punch.
what about something like
for (int a = -999; a < 1000; a++)
{
for (int b = 0; b < put size of array here; b++)
{ x = 0;
while (isPrime(x*x+a*x+primes[b]))
x++;
if (x > max)
{
max = x;
max_co = a;
max_co_sec = primes[b];
}
}
}
cout << max_co * max_co_sec << endl;
Am just a newb so this may be a stupid question, but i don't understand line 58
for (int b = -999; b < 1000; b = primes[index++])
why not
for (int b = -999; b < 1000; b++)
I've already done this but having looked at my code i'm not sure how(one off program so didn't comment on what i was doing) but both answers above are wrong although the second one is closer.
p.s what are your values for a and b?
I don't think next_permutation would work. It will give you the 24 permutations once you have generated the 4-digit number but it won't generate the numbers themselves.
as has been previously stated
int array[10]
contains 10 elements indexed from 0 to 9
if you attempt to read array[10] who knows what you will get.
#includes <iostream>;
maybe
#include <iostream>
would work better.
@FutureWebDev
There are 210 ways to choose 4 from 10 but there are 24 permutations of each therefor 5040 is correct.
@MarounMaroun
How is your 2D-array (of size [1260][4]) going to hold 5040 combinations?
This is not overly difficult but as jonsca said have a go first.
1. What is the problem?
2. Code tags code tags code tags.
@hayzam take some time and read the post from ravenous. there is plenty to be learned there.