본문 바로가기

Java446

[백준/Java] 34946번 셔틀 탈래 말래 탈래 말래 애매하긴 해 -Codeimport java.util.Scanner;public class BOJ34946 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int goStart = sc.nextInt(); int goEnd = sc.nextInt(); int walk = sc.nextInt(); int dist = sc.nextInt(); int shuttle = goStart + goEnd; System.out.println(lateCheck(shuttle, walk, dist)); } private static Stri.. 2025. 12. 26.
[백준/Java] 2485번 가로수 -Codeimport java.util.Scanner;public class BOJ2485 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); int[] nums = new int[t]; for (int i = 0; i 위가 정답 코드이나 뭔가 개선 가능할 것 같이서 아래와 같이 개선했습니다.import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in.. 2025. 12. 25.
[백준/Java] 1735번 분수 합 -Codeimport java.util.Scanner;public class BOJ1735 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int d = sc.nextInt(); // 분모 int denom = b * d; // 분자 int numer = (a * d) + (b * c); int gcd = getGcd(denom, numer); // 공약.. 2025. 12. 25.
[백준/Java] 34935번 오름차순과 비내림차순 -Codeimport java.util.Arrays;import java.util.Scanner;public class BOJ34935 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] nums = new long[n]; for (int i = 0; i = nums[i]) { flag = false; break; } } System.out.println(flag ? 1 : 0); }} 2025. 12. 25.
[백준/Java] 13241번 최소공배수 -Codeimport java.io.IOException;import java.util.Scanner;public class BOJ13241 { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); long a = sc.nextInt(); long b = sc.nextInt(); System.out.println(lcm(a, b)); sc.close(); } // 최대 공약수 private static long gcd(long a, long b) { if (b == 0) { .. 2025. 12. 24.
[백준/Java] 1934번 최소공배수 -Codeimport java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.StringTokenizer;public class BOJ1934 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); for (int i = 0; i 2025. 12. 24.