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 taoy at 2007-11-18 21:09:58 on Problem 1207
In Reply To:这两个程序有什么区别啊 Posted by:gothree at 2006-11-15 17:46:41
> #include <stdio.h>
> int store[10001]={0};
> void creat()
> {
>     int i,j;
>     for(j=1;j<10001;j++)
>     {
>         i=j;
>         while(i!=1)
>         {
>             if(i%2)
>                 i=i*3+1;
>             else
>                 i/=2;
>             store[j]++;
>         }
>         store[j]++;
>     }
> }
> int main()
> {
>     int a,b,i;
>     creat();
>     while(scanf("%d%d",&a,&b)==2)
>     {
>         int max=0,x,y;
>         if(a<b)
>         {
>             x=a;y=b;
>         }
>         else
>         {
>             x=b;y=a;
>         }
>         for(i=x;i<=y;i++)
>             if(store[i]>max)
>                 max=store[i];
>         printf("%d %d %d\n",a,b,max);
>     }
>     return 0;
> }
> this one AC 了
> #include <stdio.h>
> int store[10001]={0};
> void creat()
> {
>     int i,j;
>     for(j=1;j<10001;j++)
>     {
>         i=j;
>         while(i!=1)
>         {
>             if(i%2)
>                 i=i*3+1;
>             else
>                 i/=2;
>             store[j]++;
>         }
>         store[j]++;
>     }
>     for(i=1;i<10001;i++)
>         printf("%d %d\n",i,store[i]);
> }
> int main()
> {
>     int a,b,i;
>     creat();
>     while(scanf("%d%d",&a,&b)==2)
>     {
>         int max=0,x,y;
>         if(a<b)
>         {x=a;y=b;}
>         else
>         {x=b;y=a;}
>         for(i=x;i<=y;i++)
>             if(store[i]>max)
>                 max=store[i];
>         printf("%d %d %d\n",a,b,max);
>     }
>     return 0;
> }
> this one WA了
> what is the differeces?

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