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:代码。。。0MS。。。还以为会超时咧,水In Reply To:代码。。。0MS。。。还以为会超时咧,水 Posted by:781778304 at 2011-08-20 09:52:58 > #include<iostream> > using namespace std; > #define N 10005 > int Caculate(int j) > { > int no=1; > while(1) > { > if(j==1)break; > if(j%2==0) j/=2; > else j=3*j+1; > no++; > } > return no; > } > int main() > { > int n,m; > while(cin>>n>>m) > { > int j; > int tempn=n,tempm=m; > if(n>m){j=n;n=m;m=j;} > int max=0; > for(j=n;j<m+1;j++) > { > int temp=Caculate(j); > max=max>temp?max:temp; > } > printf("%d %d %d\n",tempn,tempm,max); //输出的时候要按照原来的顺序输出 > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator