Page 2 of 7
Posted: Mon Dec 16, 2002 11:05 am
Now I use your ideea (to precalculate the prime numbers) and I obtained a better result, 0.367s. I think that it's good enough for the moment... Thanks a lot
Posted: Fri Jan 10, 2003 10:44 am
There may be another problem in ur programs output
all the time u printed:
printf("Between %d and %d, %d has a maximum of %d divisors.n",inicio,fim,maior_n,maior);
But what is .n?
it will be \n for the new line.
cheak it once again.
294 - Divisors
Posted: Mon Sep 08, 2003 10:23 am
divisor:array[1..100000] of byte;
while x>1 do begin
while frac(x/i)<0.00000001 do begin
x:=x div i;
if i>limit then break;
for i:=1 to limit do begin
if divisor<>0 then begin
for i:=1 to n do begin
if x>y then begin
for j:=ytemp downto xtemp do begin
if now>=max then begin
writeln('Between ',x,' and ',y,', ',num,' has a maximum of ',max,' divisors.');
please help me.
I have tried 3 times, but I can't get the correct answer.
Posted: Mon Sep 08, 2003 11:42 am
Always try borderline cases:
Code: Select all
Between 1 and 1, 0 has a maximum of 2 divisors.
Posted: Thu Sep 11, 2003 4:22 pm
there is a smarter solution.
you don't need to try every divisor for a number n.
if you know its prime factors, it's easy then to compute the number of divisors.
so all you really need is a list of prime numbers (which you compute only once), then you can get prime factors of any number quickly.
Posted: Fri Sep 12, 2003 5:55 am
Using prime factors???
Could you please tell me more detail?
9000 = 2 * 2 * 2 * 3 * 3 * 5 * 5 * 5
i.e. 9000 has 3 2's, two 3's and three 5's.
How do we compute the divisors of 9000??
Posted: Fri Sep 12, 2003 1:49 pm
The number of divisors of X=(p1^i1)*(p2^i2)*...*(pn^in) equals (i1+1)*(i2+1)*...*(in+1). You can prove this using induction or by observing that a divisor of X, y = (p1^j1)*(p2^j2)*...*(pn^jn) where 0<=j1<=i1,..., 0<=jn<=in. This is basic number theory, I think you can find this and more in CLR or any number theory book.
Posted: Sun Sep 14, 2003 4:30 pm
Thanx a lot for the tips, cosmin.ro!!!
In 294,if two numbers have the same number of divisors....
Posted: Sat Oct 04, 2003 3:03 pm
how should i output my result???
Posted: Sat Oct 04, 2003 8:29 pm
For each range, find the number P which has the largest number of divisors (if several numbers tie for first place, select the lowest)...
Posted: Sun Oct 05, 2003 8:55 am
As the number growing up, i need more time to get result.
But I have used the prime's method....
So,Is there any aspect i have not notice???
294 WA.....i don't know why!!!.........
Posted: Sun Oct 05, 2003 8:21 pm
Code: Select all
bool prime(int X)
int division(int div,int X,int div_num)
cout<<"Between "<<L<<" and "<<U<<", "<<X<<" has a maximum of "<<max<<" divisors."<<endl;
i can't find what's wrong.....
Please somebody help me...~~
Posted: Fri Aug 27, 2004 11:45 am
1 have 1 divisor (after i add this case i got AC)
Cul de sac.
Posted: Sat Sep 25, 2004 3:50 am
My program from the very begining used all those tricks. Anyway, I get Wrong Answer. I think it is because of the input reading
unsigned long factores(unsigned long);
unsigned long k,n,max,i,u,q,a,l;
printf("Beetween %ld and %ld, %ld has a maximum of %ld divisors.\n",k,n,q,max);
Could anyone help?
Posted: Tue Oct 05, 2004 5:32 pm
Please give me some input ... Dunno why is error
unsigned long atas,bawah,bilangan;
printf("Between %d and %d, %ld has a maximum of %d divisors.\n",bawah,atas,bilangan,max);