問題:http://acm.pku.edu.cn/JudgeOnline/problem?id=1207
順位:http://acm.pku.edu.cn/JudgeOnline/problemstatus?problem_id=1207&language=2&orderby=clen
提出コード(244B)
import java.util.*;class Main{static{int r,a,b,c,k,i;for(Scanner s=new Scanner(System.in);(r=0)<1;){a=s.nextInt();b=s.nextInt();for(i=a<b?a:b;i<=(a>b?a:b);r=c>r?c:r,i++)for(k=i,c=1;k>1;c++)k=k%2<1?k/2:3*k+1;System.out.println(a+" "+b+" "+r);}}}
整形コード
class Main { static { int r , a, b, c, k, i; for (Scanner s = new Scanner(System.in); (r = 0) < 1;) { a = s.nextInt(); b = s.nextInt(); for (i = a < b ? a : b; i <= (a > b ? a : b); r = c > r ? c : r, i++) for (k = i, c = 1; k > 1; c++) k = k % 2 < 1 ? k / 2 : 3 * k + 1; System.out.println(a + " " + b + " " + r); } } }