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.Q15652; import java.util.Scanner; public class Main { static int[] a = new int[10]; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); /* 순서로 풀이 System.out.println(go(0, 1, n, m)); */ // 선택으로 풀이 System.out.println(go(1, 0, n, m)); } /* 순서로 풀이 private static StringBuilder go(int index, int start, int n, int m) { if (index == m) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < m; i++) { sb.append(a[i]); if (i != m - 1) sb.append(" "); } sb.append("\n"); return sb; } StringBuilder ans = new StringBuilder(); for (int i = start; i <= n; i++) { a[index] = i; //순서로 풀이 ans.append(go(index + 1, i, n, m)); } return ans; } */ static StringBuilder go(int index, int selected, int n, int m) { if (selected == m) { StringBuilder sb = new StringBuilder(); for (int i = 1; i <= n; i++) { for (int j = 1; j <= a[i]; j++) { sb.append(i); sb.append(" "); } } sb.append("\n"); return sb; } StringBuilder ans = new StringBuilder(); if (index > n) return ans; for (int i = m - selected; i>= 1; i--) { a[index] = i; ans.append(go(index + 1, selected + i, n, m)); } a[index] = 0; ans.append(go(index + 1, selected, n, m)); return ans; } }
The text was updated successfully, but these errors were encountered:
3400b9f
BOJ: 15652 풀이 수정
940e83c
Issue #58
suhyunsim
No branches or pull requests
문제
핵심 아이디어
어려운 점, 실수
풀이
The text was updated successfully, but these errors were encountered: