POJ1207-The 3n + 1 problem
生活随笔
收集整理的這篇文章主要介紹了
POJ1207-The 3n + 1 problem
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
http://poj.org/problem?id=1207
注意輸入兩個數的大小,水。。。
#include <stdio.h> int main(void) {int a,b,m,count,i,max;while(scanf("%d%d",&a,&b)!=EOF){printf("%d %d ",a,b);if(a>b){m=a;a=b;b=m;}max=0;for(i=a;i<=b;i++){m=i;count=1;while(m!=1){if(m%2)m=3*m+1;elsem/=2;count++;}if(count>max)max=count;}printf("%d\n",max);}return 0; }轉載于:https://www.cnblogs.com/YogurtShen/archive/2012/08/29/2661679.html
總結
以上是生活随笔為你收集整理的POJ1207-The 3n + 1 problem的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: tr069相关协议说明
- 下一篇: vim编辑器常用命令总结