문제풀이import java.util.Scanner;public class BertAndGongjun { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int limit = 123456 * 2; boolean[] isPrime = new boolean[limit + 1]; // 소수 판별 배열 초기화 for (int i = 2; i