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 |
帮我看看,出了啥问题?#include <stdio.h> int GetLen(int n) { int k=1; while(n!=1) { if(n%2)n=n*3+1; else n>>=1; k++; } return k; } main() { int i,n=0,m=0,max=0,t,p,q; while(scanf("%d%d",&n,&m)!=EOF) { p=n,q=m; if(n>m) { n=n^m; m=n^m; n=n^m; } for(i=n;i<=m;i++) { t=GetLen(i); if(t>max) max=t; } if(m<=n) printf("%d %d %d\n",q,p,max); else printf("%d %d %d\n",p,q,max); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator