Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

线性的算法,三个队列,一次扫描过去~~~~~

Posted by achilles at 2005-06-02 16:37:50 on Problem 1338
In Reply To:我的也超时了!! Posted by:erics at 2005-06-02 16:35:25
> #include <stdio.h>
> main()
> { int a[1501]={1500,1,0};
>   int n=1,i=2,j,m;
>   while(i<1501)
>   { 
>      n=n+1;
>      j=n;
>      while(j!=1)
>       { if(j%2==0)j=j/2;
>         else if(j%3==0) j=j/3;
>              else if(j%5==0) j=j/5;
>                   else break;
>       }
>      if(j==1)
>        {a[i]=n;i++;}
>    }
>      printf("please enter n'th ugly number:\n");
>      scanf("%d",&m);
>      printf("%d",a[m]);
> }  
> 请高人指点一下!!

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator