码迷,mamicode.com
首页 > 其他好文 > 详细

POJ 1207

时间:2015-06-09 16:23:01      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:

 1 #include <iostream>
 2 using namespace std;
 3 
 4 int main()
 5 {
 6     //freopen("acm.acm","r",stdin);
 7     int num_i;
 8     int num_j;
 9     int max;
10     int len;
11     int i;
12     int j;
13     int temp_i;
14     int temp_j;
15     while(cin>>num_i>>num_j)
16     {
17         temp_i = num_i;
18         temp_j = num_j;
19         if(num_i > num_j)
20         {
21             swap(num_i,num_j);
22         }
23         max = 0;
24         for(i = num_i; i <= num_j; ++ i)
25         {
26             j  = i;
27             len = 0;
28             while(j > 1)
29             {
30                 if(j%2 == 0)
31                 {
32                     j /= 2;
33                 }    
34                 else
35                 {
36                     j = 3*j + 1;
37                 }
38                 ++ len;
39             }
40             
41             if(len > max)
42             {
43                 max = len;
44             }
45         }
46         cout<<temp_i<<" "<<temp_j<<" "<<max+1<<endl;
47     }
48 }

 

POJ 1207

标签:

原文地址:http://www.cnblogs.com/gavinsp/p/4563328.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!