• 문제 링크
https://www.acmicpc.net/problem/8658
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int n = read(), i = 1, j = n;
while (++i < n) if (n % i != 0) break;
while (--j > 1) if (n % j != 0) break;
bw.write(i + " " + j);
bw.flush();
}
private static int read() throws IOException {
int c, n = System.in.read() & 15;
while ((c = System.in.read()) > 32) n = (n << 3) + (n << 1) + (c & 15);
return n;
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 10804 카드 역배치 - Implementation / Java (0) | 2024.11.18 |
---|---|
[백준] 20359 A simple task - Brute Force / Java (0) | 2024.11.17 |
[백준] 16625 Das Blinkenlights - Brute Force / Java (0) | 2024.11.15 |
[백준] 25270 99 Problems - Brute Force / Java (0) | 2024.11.14 |
[백준] 2061 좋은 암호 - Brute Force / Java (0) | 2024.11.13 |
댓글