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 main() { int a,b,temp,ka,kb,count,k,m,max; while(scanf("%d%d",&a,&b)!=EOF) { printf("%d %d ",a,b); if(a>b) { temp=a; a=b; b=temp; } max=0; for(k=a;k<=b;k++) { m=k; count=1; while(m!=1) { if(m%2) m=3*m+1; else m/=2; count++; } if(count>max) max=count; } printf("%d\n",max); } return 1; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator