#include<stdio.h> int main() { int count = 0; int n; scanf("%d",&n); while(n>1) { if(n%2==1) n=n*3+1; else n/=2; count++; } printf("%d\n",count); return 0; }
Problem J: 零起点学算法34——3n+1问题
猜你喜欢
转载自www.cnblogs.com/chenlong991223/p/9824876.html
今日推荐
周排行