[백준] P2908

동민·2021년 3월 11일
import java.util.Scanner;

public class P2908 {

	public static void main(String[] args) {

		int n1, n2;

		Scanner sc = new Scanner(System.in);

		n1 = sc.nextInt();
		n2 = sc.nextInt();
		
		n1 = fun(n1);
		n2 = fun(n2);
		
		System.out.println(n1>n2 ? n1 : n2);

		sc.close();

	}

	public static int fun(int n) {

		int sum = 0;

		int k, g;

		for (int i = 2; i >= 0; i--) {

			k = (int) Math.pow(10, i);
			g = (int) Math.pow(10, 2 - i);

			sum += (n / k) * g;
			
			n -= (n/k) * k;

		}

		return sum;
	}

}
profile
BE Developer

0개의 댓글