Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Brute_Force/2231_Decomposition/YoungJung2231.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;




public class YoungJung2231 {
// 생성자 찾는 메소드
public static int searshConstructor (int N) {
int result;

for (int i = 1; i < N; i++) {
result = 0;
String BR[] = Integer.toString(i).split("");
result += i;
for (int j = 0; j < BR.length; j++) {
result += Integer.parseInt(BR[j]);
}

if (result == N) {
return i;
}

}
return 0;


}
public static void main(String[] args) throws NumberFormatException, IOException {
// N의 분해합 구하기
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
System.out.println(searshConstructor(N));

}

}
50 changes: 50 additions & 0 deletions Brute_Force/2309_Seven_dwarfs/YoungJung2309.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class YoungJung2309 {
public static void Choice (int P[]) {
boolean visite[] = new boolean[9];
int sum = 0;

for (int i = 0; i < 8; i++) {
for (int j = i + 1; j < 9; j++) {
visite[i] = true;
visite[j] = true;
// false만 더함
for (int j1 = 0; j1 < 9; j1++) {
if (visite[j1] == false) {
sum += P[j1];
}
}
if (sum == 100) {
for (int j1 = 0; j1 < 9; j1++) {
if (visite[j1] == false) System.out.println(P[j1]);
}
System.exit(0);
}
else {
sum = 0;
Arrays.fill(visite, false);
}

}
}
}

public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader (new InputStreamReader(System.in));

int height[] = new int [9];

for (int i = 0; i < 9; i++) {
height[i] = Integer.parseInt(br.readLine());
}
Arrays.sort(height);
Choice(height);

}

}