본문 바로가기

PS41

백준 - 알고리즘 수업 - 피보나치 수1 재귀함수와 Dp가 수행시간이 얼마나 차이가 나는지 분석한 문제이다. import java.math.BigInteger; import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); int num = Integer.parseInt(bf.readLine()); System.out.println(fib(num)); System.out.println(num-2); } static int fib(int N) { if (N == 1 ||.. 2023. 11. 12.
백준 - 직사각형 탈출 직사각형에서 도망가~ 점과 가장 가까운 거리를 구하면 풀리는 문제였다. 솔직히 아까 풀었던 주사위 문제보다 훨씬 쉬웠다. 난이도 조정 좀 줘야될듯.. package org.example; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); String s = bf.readLine(); .. 2023. 11. 11.
백준 - 주사위 세개 아니 브론즈4인데 왜 이렇게 어렵냐고 장난함?? package org.example; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); String s = bf.readLine(); String[] split = s.split(" "); int num1 = Integer.parseIn.. 2023. 11. 11.
백준 - 최소공배수 아까 풀었던 유클리드 호제법을 이용한 문제로 최소공배수를 구해준다. 최대공약수를 알면 최소공배수도 구할 수 있음 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Stack; public class Main { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamRea.. 2023. 11. 10.