From a660238b71c102e7bf2731031516ef2c97d3131a Mon Sep 17 00:00:00 2001 From: sa11k Date: Tue, 12 Jul 2022 23:50:21 +0900 Subject: [PATCH] Feat:Add solution of #118 --- src/BaekJoon/sa11k/1920/Main.java | 51 +++++++++++++++++++++++++++++++ src/BaekJoon/sa11k/1929/Main.java | 34 +++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 src/BaekJoon/sa11k/1920/Main.java create mode 100644 src/BaekJoon/sa11k/1929/Main.java diff --git a/src/BaekJoon/sa11k/1920/Main.java b/src/BaekJoon/sa11k/1920/Main.java new file mode 100644 index 0000000..7d8c88d --- /dev/null +++ b/src/BaekJoon/sa11k/1920/Main.java @@ -0,0 +1,51 @@ +import java.util.*; +import java.io.*; + +public class Main { + static int[] input; + + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int inputNum = Integer.parseInt(br.readLine()); + input = new int[inputNum]; + + StringTokenizer st = new StringTokenizer(br.readLine(), " "); + for(int i = 0; i= 0) + System.out.println(1); + else + System.out.println(0); + } + + br.close(); + } + + public static int search(int num){ + int left = 0; + int right = input.length-1; + + while(left<=right){ + int mid = (left+right) / 2; + + if(num < input[mid]) + right = mid - 1; + + else if(num > input[mid]) + left = mid + 1; + + else + return mid; + } + + return -1; + } +} diff --git a/src/BaekJoon/sa11k/1929/Main.java b/src/BaekJoon/sa11k/1929/Main.java new file mode 100644 index 0000000..126da05 --- /dev/null +++ b/src/BaekJoon/sa11k/1929/Main.java @@ -0,0 +1,34 @@ +import java.util.*; +import java.io.*; + +public class Main { + + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine(), " "); + StringBuilder sb = new StringBuilder(); + + int M = Integer.parseInt(st.nextToken()); + int N = Integer.parseInt(st.nextToken()); + + for(int i = M; i<=N; i++){ + if(checkPrime(i)){ + sb.append(i).append("\n"); + } + } + + System.out.println(sb); + br.close(); + } + + public static boolean checkPrime(int num){ + if(num<=1) return false; + else if(num==2) return true; + else{ + for(int i = 2; i<=Math.sqrt(num); i++){ + if((num % i) == 0) return false; + } + return true; + } + } +}