본문 바로가기

전체 글

(232)
[백준 24313 JAVA 자바] 알고리즘 수업 - 점근적 표기 1 코드입니다 import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; interface Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); StringTokenizer st; String[] arr = br.readLine().split(" "); int a1 = Integer.parseInt(arr[0]), a0 = Integer.parseInt(..
[백준 24267 JAVA 자바] 알고리즘 수업 - 알고리즘의 수행 시간 6 3중 for문입니다 마지막 sum 코드는 총 몇번 반복하는지 생각해봅시다 코드입니다 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); Long n = scan.nextLong(); Long t = n*(n-1)*(n-2)/6; System.out.println(t+"\n"+3); } } 시그마를 이용해 총 몇번 반복하는지 구합시다
[백준 24266 JAVA 자바] 알고리즘 수업 - 알고리즘의 수행 시간 5 3중 for문입니다 지금까지 하던대로 하면 됩니다 코드입니다 import java.util.Scanner; public class Main { static int count = 0; public static void main(String[] args) { Scanner scan = new Scanner(System.in); Long n = scan.nextLong(); Long t = n*n*n; System.out.println(t+"\n"+3); } }
[백준 24265 JAVA 자바] 알고리즘 수업 - 알고리즘의 수행 시간 4 또 2중 for문이네요 코드입니다 import java.util.Scanner; public class Main { static int count = 0; public static void main(String[] args) { Scanner scan = new Scanner(System.in); Long n = scan.nextLong(); Long t = n*(n-1)/2; System.out.println(t+"\n"+2); } }
[백준 24264 JAVA 자바] 알고리즘 수업 - 알고리즘의 수행 시간 3 이 문제는 2중 for문 입니다 2중 for문의 반복도는 어느정도 일까요? 코드입니다 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); long n = scan.nextLong(); long t = n*n; System.out.println(t+"\n"+2); } } 단순히 첫번째 반복을 n번하고 두번째 반복을 n번 한다고 생각하면 총 n^2만큼 반복하게 됩니다
[백준 24263 JAVA 자바] 알고리즘 수업 - 알고리즘의 수행 시간 2 코드 1 은 for문 안에 있습니다 이걸 생각해서 문제를 풉시다 코드입니다 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); System.out.println(n+"\n"+1); } } n이 입력 됐을 때 n만큼 반복하게 되니깐 최고차항의 차수는 1입니다
[백준 24262 JAVA 자바] 알고리즘 수업 - 알고리즘의 수행 시간 1 함수를 실행했을 때 코드를 컴퓨터가 총 몇번 읽나 생각하는 문제입니다 컴퓨터가 됐다 생각하고 해봅시다 코드입니다 public class Main { public static void main(String[] args) { System.out.println(1+"\n"+0); } } 1
[백준 24086 JAVA 자바] 身長 (Height) 키가 얼마나 자랐는지 구해봅시다 코드입니다 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int a = scan.nextInt(); int b = scan.nextInt(); System.out.println(Math.abs(a-b)); } } 단순한 빼기입니다