전체 글 (271) 썸네일형 리스트형 [백준_JAVA_알고리즘] 24313 알고리즘 수업 - 점근적 표기 1 import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int a1 = scanner.nextInt(); int a0 = scanner.nextInt(); int c = scanner.nextInt(); int n0 = scanner.nextInt(); if((a1*n0+a0 [백준_JAVA_알고리즘] 24267 알고리즘 수업 - 알고리즘의 수행 시간 6 import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); long n = scanner.nextInt(); System.out.println((n*(n-1)*(n-2))/6); System.out.println(3); scanner.close(); } } 공식은 nC3이다. [백준_JAVA_알고리즘] 24266 알고리즘 수업 - 알고리즘의 수행 시간 5 import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); long n = scanner.nextInt(); System.out.println(n*n*n); System.out.println(3); scanner.close(); } } 3중 for문이다. [백준_JAVA_알고리즘] 24265 알고리즘 수업 - 알고리즘의 수행 시간 4 import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); long n = scanner.nextInt(); System.out.println((n*(n-1))/2); System.out.println(2); scanner.close(); } } 등차수열의 합이다. (n*(n-1))/2 [백준_JAVA_알고리즘] 24264 알고리즘 수업 - 알고리즘의 수행 시간 3 import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); System.out.println(n * n); System.out.println(2); scanner.close(); } } 다음은 틀린 코드이다.. n의 자료형을 long으로 바꾸면 된다. import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); long n .. [백준_JAVA_알고리즘] 24263 알고리즘 수업 - 알고리즘의 수행 시간 2 import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); System.out.println(n); System.out.println(1); scanner.close(); } } 시간 복잡도 O(n)이다. n은 7번 수행 수행 시간은 1이다 [백준_JAVA_알고리즘] 24262 알고리즘 수업 - 알고리즘의 수행 시간 1 public class Main { public static void main(String[] args){ System.out.println('1'); System.out.println('0'); } } 시간 복잡도를 몰라서 코드가 이해가지 않았다. 인프런 강의에서 Do it! 알고리즘 코딩테스트 with JAVA를 참고했다. 시간 복잡도 주어진 문제를 해결하기 위한 연산 횟수 (1초에 1억 번 연산) Big-Ω (빅-오메가): 최선 Big-θ (빅-세타): 보통 -> N/2 Big-O (빅-오): 최악 => 코딩 테스트에서 고려해야 할 test case!! ex. O(n), O(n^2)... 버블 정렬: n^2 병합 정렬: nlog(n) 특징 1. 상수는 무시 2. 이중 for문은 N^2, 가장 많이 .. [백준_JAVA] 9063 대지 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); while(true) { int num = scan.nextInt(); int[] x = new int[num]; int[] y = new int[num]; int maxX = Integer.MIN_VALUE; int minX = Integer.MAX_VALUE; int maxY = Integer.MIN_VALUE; int minY = Integer.MAX_VALUE; for(int i = 0; i < num; i++) { x[i] = scan.nextInt(); y[i] = sca.. 이전 1 ··· 8 9 10 11 12 13 14 ··· 34 다음 목록 더보기