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

Re:为什么会超时呢?是不是我的程序在算法上有问题?

Posted by ericsummer at 2005-08-11 00:51:19 on Problem 2453
In Reply To:为什么会超时呢?是不是我的程序在算法上有问题? Posted by:tcxgsy at 2005-08-06 10:55:01
> #include"stdio.h"
> #include"math.h"
> 
> main()
> {int i=1,n,b=0,d=0,c;
>  long int a[1001],m;
>     while(scanf("%ld",&a[i])&&a[i])   //输入
>        {
>              while(a[i]!=0)
>                     {c=a[i]%2;a[i]/=2;b+=c;}  //将输入的数据花为二进制,看看1的个数; 
>             while(d!=b)        //从输入的数据开始向上找,判断它化为二进制后的1的个数是否与前者相同
>                {  while(++a[i]!=0)    若相同  则输出哪个数。
>                      {   m=a[i];       这是我的基本思路,希望你们可以看看,敬请指教。
>                           c=m%2;m/=2;d+=c;}
>                 }   
>             printf("%ld\n",a[i]);
>             i++;
>         }
>  }  
> 

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