import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
        int[] wallet_1 = {30, 15};
        int[] bill_1 = {26, 17};
        
        int[] wallet_2 = {50, 50};
        int[] bill_2 = {100, 241};
        
        //System.out.print(solution(wallet_1, bill_1));
        System.out.print(solution(wallet_2, bill_2));
    }
    
    public static int solution(int[] wallet, int[] bill) {
        int answer = 0;
        
        int x = bill[0];
        int y = bill[1];
        
        int x_tmp = x;
        int y_tmp = y;
        
        while (true) {
            System.out.println("Wallet:"+wallet[0]+":"+wallet[1]+"/Bill:"+x+":"+y);
            if(wallet[0] < x || wallet[1] < y) {
                x = y_tmp;
                y = x_tmp;
                
                System.out.println("[90Trun] Wallet:"+wallet[0]+":"+wallet[1]+"/Bill:"+x+":"+y+"\n");
                if(wallet[0] < x || wallet[1] < y) {
                    if(x_tmp >= y_tmp) {
                        x = x_tmp / 2;
                        x_tmp = x;
                        y = y_tmp;
                    }
                    else {
                        y = y_tmp / 2;
                        y_tmp = y;
                        x = x_tmp;
                    }
                    answer++;
                }
            }
            else {
                break;
            }
        }
        
        return answer;
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: