标签:
题目链接:http://poj.org/problem?id=1207
#include <stdio.h> #include <algorithm> using namespace std; int i,j; int Max; int fun(int k) { int Count=1; while(k!=1) { if(k%2==1) k=k*3+1; else k/=2; Count++; } return Count; } int main() { while(scanf("%d%d",&i,&j)!=EOF) { int ti=i; int tj=j; Max=-1; if(ti>tj) swap(ti,tj); for(int k=ti; k<=tj; k++) { if(Max<fun(k)) { Max=fun(k); } } printf("%d %d %d\n",i,j,Max); } return 0; }
标签:
原文地址:http://www.cnblogs.com/TreeDream/p/5304124.html