| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:这两个程序有什么区别啊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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator