We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package main.java.com.poogle.BOJ.Q1463; import java.util.Scanner; public class Main { static int[] d; public static int go(int n) { if (n == 1) return 0; if (d[n] > 0) return d[n]; d[n] = go(n - 1) + 1; if (n % 2 == 0) { int tmp = go(n / 2) + 1; if (d[n] > tmp) d[n] = tmp; } if (n % 2 == 0) { int tmp = go(n / 3) + 1; if (d[n] > tmp) d[n] = tmp; } return d[n]; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); d = new int[n + 1]; System.out.println(go(n)); } }
package main.java.com.poogle.BOJ.Q1463; import java.util.Scanner; public class Main { static int[] d; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); d = new int[n + 1]; d[1] = 0; for (int i = 2; i <= n; i++) { d[i] = d[i - 1] + 1; if (i % 2 == 0 & d[i] > d[i / 2] + 1) { d[i] = d[i / 2] + 1; } if (i % 3 == 0 & d[i] > d[i / 3] + 1) { d[i] = d[i / 3] + 1; } } System.out.println(d[n]); } }
The text was updated successfully, but these errors were encountered:
BOJ: 1463 풀이
397a9c4
- 재귀로 풀이 Issue #111
1314749
suhyunsim
No branches or pull requests
문제
핵심 아이디어
어려운 점, 실수
풀이
재귀로 풀이 (Top Down)
Bottom up
The text was updated successfully, but these errors were encountered: