본문 바로가기

Java445

[백준/Java] 1978번 소수 찾기 -Codeimport java.util.Scanner;public class BOJ1978 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int cnt = 0; for (int i = 0; i 2025. 12. 21.
[백준/Java] 9506번 약수들의 합 -Codeimport java.util.ArrayList;import java.util.List;import java.util.Scanner;public class BOJ9506 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { int n = sc.nextInt(); if (n == -1) break; List measure = new ArrayList(); int sum = 0; for (int m = 1; m 2025. 12. 21.
[백준/Java] 2501번 약수 구하기 -Codeimport java.util.Scanner;public class BOJ2501 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int cnt = 0, answer = 0; for (int i = 1; i 2025. 12. 21.
[백준/Java] 5086번 배수와 약수 -Codeimport java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.StringTokenizer;public class BOJ5086 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (true) { StringTokenizer st = new StringTokenizer(br.readLine()).. 2025. 12. 21.
[백준/Java] 2869번 달팽이는 올라가고 싶다 -Codeimport java.util.Scanner;public class BOJ2869 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int v = sc.nextInt(); // 다음날 낮이면 도달 가능한 거리 구함 // 그 값을 하루 이동 거리로 나누고 반올림 // 다음날 낮에 도달하므로 +1 int answer = (int) Math.ceil((double) (v - a) / (a - b)) + 1; Syst.. 2025. 12. 21.
[백준/Java] 1193번 분수찾기 -Codeimport java.util.Scanner;public class BOJ1193 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); System.out.println(solution(n)); } private static String solution(int num) { int temp = 0; int now = 0; while (temp 위와 같이 해결했으나 너무 복잡하게 푼거 같아서 개선 받은 코드로 다시 작성해 봤습니다.import java.util.Scanner;publ.. 2025. 12. 21.