import java.util.*; import java.lang.*; public class Main{ public static void main(String[] args){ Scanner cin = new Scanner(System.in); while( cin.hasNext() ){ int i = cin.nextInt(); int j = cin.nextInt(); int k , max=0 ,count , a=i , b=j , c=0; if(a>b){ c=a; a=b; b=c; } for(k=a ; k<=b ; k++){ int temp = k; count=1; while(temp!=1){ if(temp%2!=0) temp=3*temp+1; else temp=temp/2; count++; } if(count>max) max=count; } System.out.println(i+" "+j+" "+max); } } }
2014-06-30
100-The 3n + 1 problem
訂閱:
張貼留言 (Atom)
(VM) Ubuntu enable ssh
OS版本:14.04 LTS 相關指令: sudo apt-get install openssh-server Port forwarding設定 : 以virtual box為例子,網路->進階->連接阜轉送(port forwarding) ...
-
https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1849
沒有留言:
張貼留言