diff --git a/chris-an/home/3.11/Boj_10872.java b/chris-an/home/3.11/Boj_10872.java new file mode 100644 index 00000000..22c4961d --- /dev/null +++ b/chris-an/home/3.11/Boj_10872.java @@ -0,0 +1,16 @@ +import java.util.Scanner; + +public class Boj_10872 { + + static int value = 1; + public static int factorial(int n) { + if (n == 0) return value; + value *= n ; + return factorial(n-1); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.println(factorial(sc.nextInt())); + } +} diff --git a/chris-an/home/3.11/Boj_1676.java b/chris-an/home/3.11/Boj_1676.java new file mode 100644 index 00000000..8438aade --- /dev/null +++ b/chris-an/home/3.11/Boj_1676.java @@ -0,0 +1,44 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + + +public class Boj_1676 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int n = Integer.parseInt(br.readLine()); + int cnt = 0; + for (int i = 5; i <= n ; i *= 5) { + cnt += n / i; + } + + System.out.println(cnt); + } +} + +/* + +public class Main { + + static int value = 1; + + public static int factorial(int n) { + if (n == 0) return value; + value *= n; + return factorial(n - 1); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int N = factorial(sc.nextInt()); + char [] ch = Integer.toString(N).toCharArray(); + + int cnt = 0; + for (int i = ch.length-1; i > 0; i--) { + if (ch[i] == '0') cnt++; + else break; + } + System.out.println(cnt); + } +} + */ \ No newline at end of file diff --git a/chris-an/home/3.11/Boj_6588.java b/chris-an/home/3.11/Boj_6588.java new file mode 100644 index 00000000..70089008 --- /dev/null +++ b/chris-an/home/3.11/Boj_6588.java @@ -0,0 +1,91 @@ +import java.io.*; +import java.util.Arrays; + + +public class Boj_6588 { + static boolean [] targetNumbers; + public static void isPrime() { + targetNumbers = new boolean[1000001]; + + Arrays.fill(targetNumbers, true); +// for(int i=2;i<=N;i++) { +// targetNumbers[i] = true; +// } + for (int i = 2; i<=1000000; i++) { + // 이미 확인된 건 넘기기 + if (!targetNumbers[i]) continue; + // 배수 출발. + for (int j = i * 2; j <= 1000000; j += i ) targetNumbers[j] = false; + } + } + public static void main(String[] args) throws IOException { + + + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + isPrime(); + while (true) { + int n = Integer.parseInt(br.readLine()); + if (n == 0) break; + + int primeNum = Integer.MIN_VALUE; + for (int i = 2; i <= n/2; i++) { + if (targetNumbers[i] && targetNumbers[n-i]) { + primeNum = i; + break; + } + } + + if (primeNum > 0) bw.write(n + " = " + primeNum + " + " + (n-primeNum) + "\n"); + else bw.write("Goldbach's conjecture is wrong.\n"); + } + bw.flush(); + bw.close(); + br.close(); + } +} + + +/* + + 시간 초과. + +public class Main { + public static String isPrime(int n) { + ArrayList list = new ArrayList<>(); + boolean [] prime = new boolean[n+1]; + Arrays.fill(prime, true); + prime[0] = prime[1] = false; + for (int i = 2; i <= Math.sqrt(prime.length); i++) { + if (prime[i]) { + for (int j = i*i; j <= n; j+=i) prime[j] = false; + } + } + for (int i = 2; i < n; i++) { + if (true == prime[i]) { + list.add(i); + } + } + for (int i = 0; i < list.size(); i++) { + for (int k = i; k < list.size(); k++) { + if (list.get(i)+list.get(k) == n) { + return n + " = " + list.get(i) + " + " + list.get(k); + } + } + } + return "Goldbach's conjecture is wrong."; + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int stop = 1; + while (stop != 0) { + stop = Integer.parseInt(br.readLine()); + if (stop!=0) { + System.out.println(isPrime(stop)); + } + } + } +} + + */ diff --git a/chris-an/office/3.08/Programmers_42840.java b/chris-an/office/3.08/Programmers_42840.java new file mode 100644 index 00000000..7aab610c --- /dev/null +++ b/chris-an/office/3.08/Programmers_42840.java @@ -0,0 +1,2 @@ +public class Programmers_42840 { +} diff --git a/chris-an/office/3.10/Programmers_42839.java b/chris-an/office/3.10/Programmers_42839.java new file mode 100644 index 00000000..3ac7a184 --- /dev/null +++ b/chris-an/office/3.10/Programmers_42839.java @@ -0,0 +1,51 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.HashSet; + +public class Programmers_42839 { + + static HashSet hs = new HashSet<>(); + + public static void recur(String candidate, String remain) { + // base case 라고 불림. + if (!candidate.equals("")) hs.add(candidate); + for (int i = 0; i < remain.length(); i++){ + recur(candidate + remain.charAt(i), remain.substring(0, i) + remain.substring(i+1)); + } + } + + public static boolean isPrime(int n) { + // 0, 1 는 제외 + if (n < 2) return false; + // true = 소수, false = 합성수 + boolean [] prime = new boolean[n+1]; + Arrays.fill(prime, true); + + prime[0] = prime[1] = false; + for (int i = 2; i*i <= n; i++) { + // 소수가 아니라면? + if (prime[i]) { + for (int j = i*i; j <= n; j+=i) prime[j] = false; + } + } + return prime[n]; + } + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + String str = br.readLine(); + + recur("", str); + int cnt = 0; + + for (String s : hs) { + if (isPrime(Integer.parseInt(s))) + cnt++; + } + + System.out.println(cnt); + + } +} diff --git a/chris-an/office/3.10/Programmers_42842.java b/chris-an/office/3.10/Programmers_42842.java new file mode 100644 index 00000000..29a47e7c --- /dev/null +++ b/chris-an/office/3.10/Programmers_42842.java @@ -0,0 +1,38 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class Programmers_42842 { + + public static int [] solution(int brown, int yellow) { + /* + int a = brown/2 + 2; + int b = yellow + brown; + + double alpha = (a+Math.sqrt(a*a - 4*b)) / 2; + double beta = a - alpha; + + int [] answer = {(int) alpha, (int) beta}; + */ + + int[] answer = new int[2]; + + for(int i = 1; i <= yellow; i++) { + if(yellow % i == 0) { + if(2 * i + (2 * yellow / i) == brown - 4) { + answer[0] = i + 2; + answer[1] = yellow / i + 2; + } + } + } + return answer; + } + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + String [] ch = br.readLine().split(" "); + int b = Integer.parseInt(ch[0]); + int y = Integer.parseInt(ch[1]); + + System.out.println(solution(b,y)[0] +" " + solution(b,y)[1]); + } +} diff --git a/chris-an/out/production/chris-an/Boj_10430.class b/chris-an/out/production/chris-an/Boj_10430.class new file mode 100644 index 00000000..d0e82fa2 Binary files /dev/null and b/chris-an/out/production/chris-an/Boj_10430.class differ diff --git a/chris-an/out/production/chris-an/Boj_10809.class b/chris-an/out/production/chris-an/Boj_10809.class new file mode 100644 index 00000000..d97ef94b Binary files /dev/null and b/chris-an/out/production/chris-an/Boj_10809.class differ diff --git a/chris-an/out/production/chris-an/Boj_10820.class b/chris-an/out/production/chris-an/Boj_10820.class new file mode 100644 index 00000000..3e5944aa Binary files /dev/null and b/chris-an/out/production/chris-an/Boj_10820.class differ diff --git a/chris-an/out/production/chris-an/Boj_10824.class b/chris-an/out/production/chris-an/Boj_10824.class new file mode 100644 index 00000000..230411e5 Binary files /dev/null and b/chris-an/out/production/chris-an/Boj_10824.class differ diff --git a/chris-an/out/production/chris-an/Boj_11655.class b/chris-an/out/production/chris-an/Boj_11655.class new file mode 100644 index 00000000..fe4850b5 Binary files /dev/null and b/chris-an/out/production/chris-an/Boj_11655.class differ diff --git a/chris-an/out/production/chris-an/Boj_11656.class b/chris-an/out/production/chris-an/Boj_11656.class new file mode 100644 index 00000000..9beb7668 Binary files /dev/null and b/chris-an/out/production/chris-an/Boj_11656.class differ diff --git a/chris-an/out/production/chris-an/Boj_1929.class b/chris-an/out/production/chris-an/Boj_1929.class new file mode 100644 index 00000000..9033effe Binary files /dev/null and b/chris-an/out/production/chris-an/Boj_1929.class differ diff --git a/chris-an/out/production/chris-an/Boj_1934.class b/chris-an/out/production/chris-an/Boj_1934.class new file mode 100644 index 00000000..c4672422 Binary files /dev/null and b/chris-an/out/production/chris-an/Boj_1934.class differ diff --git a/chris-an/out/production/chris-an/Boj_1978.class b/chris-an/out/production/chris-an/Boj_1978.class new file mode 100644 index 00000000..e6778efa Binary files /dev/null and b/chris-an/out/production/chris-an/Boj_1978.class differ diff --git a/chris-an/out/production/chris-an/Boj_2609.class b/chris-an/out/production/chris-an/Boj_2609.class new file mode 100644 index 00000000..8d4bf9ed Binary files /dev/null and b/chris-an/out/production/chris-an/Boj_2609.class differ diff --git a/chris-an/out/production/chris-an/Boj_2743.class b/chris-an/out/production/chris-an/Boj_2743.class new file mode 100644 index 00000000..e56a5a14 Binary files /dev/null and b/chris-an/out/production/chris-an/Boj_2743.class differ diff --git a/chris-an/out/production/chris-an/Programmers_42839.class b/chris-an/out/production/chris-an/Programmers_42839.class new file mode 100644 index 00000000..7711262a Binary files /dev/null and b/chris-an/out/production/chris-an/Programmers_42839.class differ diff --git a/chris-an/out/production/chris-an/Programmers_42840.class b/chris-an/out/production/chris-an/Programmers_42840.class new file mode 100644 index 00000000..fd4dce3e Binary files /dev/null and b/chris-an/out/production/chris-an/Programmers_42840.class differ diff --git a/chris-an/out/production/chris-an/Programmers_42842.class b/chris-an/out/production/chris-an/Programmers_42842.class new file mode 100644 index 00000000..a19fd3d6 Binary files /dev/null and b/chris-an/out/production/chris-an/Programmers_42842.class differ