1001. 害死人不偿命的(3n+1)猜想

 1 /*
 2  * Main.c
 3  * 1001. 害死人不偿命的(3n+1)猜想
 4  *  Created on: 2014年8月27日
 5  *      Author: Boomkeeper
 6  *********测试通过*******
 7  */
 8 
 9 #include <stdio.h>
10 
11 int main(void){
12 
13     int n;//题目中n
14     int count=0;//计数
15 
16     scanf("%d",&n);
17 
18     while(n!=1){
19         if(n%2==0){
20             n/=2;
21         } else{
22             n=(3*n+1)/2;
23         }
24         count++;
25     }
26 
27     printf("%d\n",count);
28 
29     return 0;
30 }

 

题目链接:

http://pat.zju.edu.cn/contests/pat-b-practise/1001

 

posted @ 2014-08-27 22:36  Boomkeeper  Views(272)  Comments(0Edit  收藏  举报
最好的流量统计 网站流量计数器