Skip to content

Commit 6566146

Browse files
authored
Merge pull request SSAFY-10th-Seoul17#10 from MadCom96/main
황진하 / 7월 4주차 / 월
2 parents fe61da5 + 99d3ec8 commit 6566146

4 files changed

Lines changed: 158 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,3 +634,4 @@ FodyWeavers.xsd
634634
.factorypath
635635
.gitignore
636636

637+
.DS_Store

HwangJinHa/BOJ/boj1543.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import java.util.Scanner;
2+
3+
public class boj1543 {
4+
static String docs = "";
5+
static String sub = "";
6+
7+
static boolean check(int idx) {
8+
// System.out.println(idx + " 부터 검");
9+
for (int i = 0; i < sub.length(); i++) {
10+
// System.out.println(docs.charAt(idx + i) + " " + sub.charAt(i));
11+
if (docs.charAt(idx + i) != sub.charAt(i)) {
12+
return false;
13+
}
14+
}
15+
return true;
16+
}
17+
18+
public static void main(String[] args) {
19+
Scanner sc = new Scanner(System.in);
20+
21+
docs = sc.nextLine();
22+
sub = sc.nextLine();
23+
24+
int end = docs.length() - sub.length();
25+
26+
int cnt = 0;
27+
for (int i = 0; i < end + 1; i++) {
28+
if (check(i)) {
29+
cnt++;
30+
i += sub.length() - 1;
31+
}
32+
}
33+
System.out.println(cnt);
34+
}
35+
}

HwangJinHa/BOJ/boj17103.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import java.util.Arrays;
2+
import java.util.Scanner;
3+
4+
public class boj17103 {
5+
static int n;
6+
// 소수일때 false
7+
static boolean[] sosu;
8+
9+
public static void main(String[] args) {
10+
Scanner sc = new Scanner(System.in);
11+
12+
sosu = new boolean[1000001];
13+
for(int i = 2; i < 1000001; i++) {
14+
// 소수가 아닌경우
15+
if (sosu[i]) {
16+
continue;
17+
}
18+
int idx = 2;
19+
int num = idx * i;
20+
while (num < 1000001) {
21+
sosu[num] = true;
22+
idx++;
23+
num = idx * i;
24+
}
25+
}
26+
sosu[1] = true;
27+
28+
// System.out.println(Arrays.toString(sosu));
29+
30+
int t = sc.nextInt();
31+
while (t-- != 0) {
32+
int num = sc.nextInt();
33+
int cnt = 0;
34+
for (int i = 1; i <= num / 2; i++) {
35+
if (!sosu[i] && !sosu[num-i]) {
36+
cnt++;
37+
// System.out.println(i + " " + (num - i));
38+
}
39+
}
40+
System.out.println(cnt);
41+
42+
}
43+
44+
}
45+
}

HwangJinHa/BOJ/boj7490.java

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import java.util.Scanner;
2+
3+
public class boj7490 {
4+
static int n;
5+
static char[] crr;
6+
static char[] letters = {' ', '+', '-'};
7+
8+
static boolean checkIfWork() {
9+
int[] nums = new int[n];
10+
int idx = 0;
11+
int tmp = 1;
12+
for(int i = 0; i < n; i++) {
13+
if (i == n - 1) {
14+
nums[idx++] = tmp;
15+
break;
16+
}
17+
18+
if (crr[i] == ' ') {
19+
tmp = tmp * 10 + i + 2;
20+
}
21+
else {
22+
nums[idx++] = tmp;
23+
tmp = i + 2;
24+
}
25+
}
26+
27+
idx = 0;
28+
int result = nums[idx++];
29+
for(int i = 1; i < n; i++) {
30+
if (crr[i - 1] == ' ') {
31+
continue;
32+
}
33+
else if (crr[i - 1] == '+') {
34+
result += nums[idx++];
35+
}
36+
else if (crr[i - 1] == '-') {
37+
result -= nums[idx++];
38+
}
39+
}
40+
41+
return (result == 0)? true : false;
42+
}
43+
44+
static void crrToString() {
45+
for(int i = 0; i < n - 1; i++) {
46+
System.out.print("" + (i+1) + crr[i]);
47+
}
48+
System.out.println(n);
49+
}
50+
51+
static void dfs(int depth) {
52+
if (depth == n - 1) {
53+
if (checkIfWork()) {
54+
crrToString();
55+
}
56+
return;
57+
}
58+
59+
for(int i = 0; i < 3; i++) {
60+
crr[depth] = letters[i];
61+
dfs(depth + 1);
62+
}
63+
}
64+
65+
public static void main(String[] args) {
66+
Scanner sc = new Scanner(System.in);
67+
68+
int t = sc.nextInt();
69+
for (int test_case = 0; test_case < t; test_case++) {
70+
n = sc.nextInt();
71+
crr = new char[n - 1];
72+
dfs(0);
73+
74+
System.out.println();
75+
}
76+
}
77+
}

0 commit comments

Comments
 (0)