Page 2 of 2
Re: 11960 Divisor Game Getting WA!!
Posted: Sun Aug 07, 2011 2:20 pm
by plamplam
Sure thing I don't mind sharing but I thought you got AC (from the above posts). Why bother with this problem? If you still want to know what my solution is then PM me with your email.
Getting TLE!!!
Posted: Fri Jun 22, 2012 7:01 pm
by mahade hasan
hy I think prime factorization needs more time so i try this .....
But get TLE.....Any one plz help me...........plz
Code: Select all
#include<stdio.h>
#include<math.h>
long Number[1000009]={0,1};
void Cal()
{
long I,K,N;
for(I=2;I<1000001;I++)
{
for(K=(double)sqrt(I);K>1;K--)
{
if(I%K==0)
{
N=I/K;
if(N==K) ++Number[I];
else Number[I]+=2;
}
}
Number[I]+=2;
}
}
int main()
{
long I,K,L,M,N,Test;
Cal();
scanf("%ld",&Test);
for(;Test>0;Test--)
{
L=1;M=1;
scanf("%ld",&N);
for(I=N;I>1;I--)
if(Number[I]>M)
{
M=Number[I];
L=I;
}
printf("%ld\n",L);
}
return 0;
}
[/color]
Re: 11960 Divisor Game Getting WA!!
Posted: Tue Jun 26, 2012 12:34 am
by brianfry713
First precompute the primes.
Re: 11960 Divisor Game Getting WA!!
Posted: Fri Jul 11, 2014 4:17 pm
by Faithkeeper_Rangwan
I don't think this problem even need to use prime factorization.
Re: 11960 Divisor Game Getting WA!!
Posted: Wed Feb 21, 2018 5:09 pm
by Zyaad Jaunnoo
Faithkeeper_Rangwan wrote: Fri Jul 11, 2014 4:17 pm
I don't think this problem even need to use prime factorization.
I modified the sieve of Eratosthenes to count the number of divisors for all N <= 1,000,000.