• 문제 링크
https://www.acmicpc.net/problem/20359
• 풀이 코드
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(), p = 0;
if (n % 2 == 0) do p++; while ((n /= 2) % 2 == 0);
bw.write(n + " " + p);
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' 카테고리의 다른 글
[백준] 2846 오르막길 - Implementation / Java (0) | 2024.11.19 |
---|---|
[백준] 10804 카드 역배치 - Implementation / Java (0) | 2024.11.18 |
[백준] 8658 Liczba - Brute Force / Java (0) | 2024.11.16 |
[백준] 16625 Das Blinkenlights - Brute Force / Java (0) | 2024.11.15 |
[백준] 25270 99 Problems - Brute Force / Java (0) | 2024.11.14 |
댓글