본문 바로가기

CODING TEST55

[java] 문제 044 (백준 1033) 문제수들의 합 5 교재 풀이import java.io.BufferedWriter;import java.io.OutputStreamWriter;import java.util.*;public class P1033_칵테일 { static ArrayList[] A; static long lcm; static boolean visited[]; static long D[]; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int N = .. 2024. 6. 21.
[java] 문제 043 (백준 1850) 문제최대공약수 교재 풀이import java.io.BufferedWriter;import java.io.OutputStreamWriter;import java.util.*;public class P1850_최대공약수 { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); long a = sc.nextLong(); long b = sc.nextLong(); long result = gcd(a, b); while (resul.. 2024. 6. 21.
[java] 문제 042 (백준 1934) 문제최소공배수 교재 풀이import java.util.*;public class P1934_최소공배수 { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int i = 0; i  내 풀이) 24.6.21에 풀다가 gcd return 어떻게 할지 고민하다 정답 보고 미완성import java.util.*;import java.io.*;public class Main{ public static void main(String[] args) throws IOException{ BufferedReader br=new Buffe.. 2024. 6. 21.
[java] 문제 041 (백준 11689) 문제GCD(n,k)=1 교재 풀이import java.io.*;public class P11689_GCDNK1 { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); long n = Long.parseLong(br.readLine()); long result = n; for (long p = 2; p 1) // 아직 소인수 구성이 남아있는 경우//(반복문에서 제곱근까지만 탐색했기 때문에 1개의 소인수가 누락되는 케이스) result = result - result / n; System.. 2024. 6. 21.
[java] 문제040 (백준 1016) 문제제곱ㄴㄴ수 교재 풀이import java.util.*;public class P1016_제곱이아닌수 { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); long Min = sc.nextLong(); long Max = sc.nextLong(); boolean[] Check = new boolean[(int) (Max - Min + 1)]; // 최대 최소 차이만큼 배열 선언 // 2의 제곱수인 4부터 max보다 작거나 같은 까지 반복 for (long i = 2; i * i  내 풀이) 24.6.20에 풀고 틀림import java.util.*;i.. 2024. 6. 20.
[java] 문제 039 (백준 1747) 문제소수&팰린드롬 교재 풀이import java.util.Scanner;public class P1747_소수팰린드롬 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] A = new int[10000001]; // N의 범위까지 소수 구해주기 for (int i = 2; i  내 풀이) 24.6.20에 풀고 맞음import java.util.*;import java.io.*;public class Main{ public static void main(String[] args) throws IOException{ Scanner sc=new .. 2024. 6. 20.
[java] 문제 038 (백준 1456) 문제거의 소수 교재 풀이import java.util.Scanner;public class P1456_거의소수 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long Min = sc.nextLong(); long Max = sc.nextLong(); long[] A = new long[10000001]; for (int i = 2; i = (double)Min/(double)temp ) { count++; } temp = temp * A[i]; } } } System.out.println(count.. 2024. 6. 20.
[java] 문제 037 (백준 1929) 문제수들의 합 5 교재 풀이import java.util.Scanner;public class P1929_소수구하기 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int M = in.nextInt(); int N = in.nextInt(); int[] A = new int[N + 1]; for (int i = 2; i  내 풀이) 24.6.19에 풀고 아깝게 틀림import java.util.*;import java.io.*;public class Main{ public static void main(String[] args) throws IOException{ Sca.. 2024. 6. 19.