11960 Divisor Game Getting WA!!

All about problems in Volume CXIX. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Re: 11960 Divisor Game Getting WA!!

Postby plamplam » Sun Aug 07, 2011 2:20 pm

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.
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson
User avatar
plamplam
Experienced poster
 
Posts: 151
Joined: Fri May 06, 2011 11:37 am

Getting TLE!!!

Postby mahade hasan » Fri Jun 22, 2012 7:01 pm

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;
}
we r surrounded by happiness
need eyes to feel it!
User avatar
mahade hasan
Learning poster
 
Posts: 70
Joined: Thu Dec 15, 2011 3:08 pm
Location: University of Rajshahi,Bangladesh

Re: 11960 Divisor Game Getting WA!!

Postby brianfry713 » Tue Jun 26, 2012 12:34 am

First precompute the primes.
brianfry713
Guru
 
Posts: 1863
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Previous

Return to Volume CXIX

Who is online

Users browsing this forum: No registered users and 1 guest