Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class Main {
- public static void main(String[] args) throws NumberFormatException, IOException{
- BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
- String line;
- while((line = in.readLine()) != null){
- int[] pairs = new int[2];
- int x = 0;
- for(String i : line.split(" ")){
- if(line.split(" ").length == 2){
- pairs[x] = Integer.parseInt(i);
- x++;
- }
- }
- blah(pairs[0], pairs[1]);
- }
- }
- public static void blah(int num1, int num2){
- final int cNum1 = num1;
- final int cNum2 = num2;
- int max = 0;
- int counter = 0;
- if(num1 > num2){
- int temp = num1;
- num1 = num2;
- num2 = temp;
- }
- for(int x = num1; x <= num2; x++){
- counter = 0;
- int j = x;
- while(j != 1){
- counter++;
- if( j % 2 == 0){
- j = j / 2;
- }
- else{
- j = (j * 3) + 1;
- }
- }
- if(counter > max){
- max = counter;
- }
- }
- System.out.println(cNum1 + " " + cNum2 + " " + max);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement