2742 기찍N

2742 기찍N

import java.util.Scanner; public class pickN2741 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); StringBuffer sb = new StringBuffer(); for(int i=a; i>0; i--) { sb.append(a--); sb.append("

"); } System.out.println(sb); } }

sb.append(a--); sb.append("

");

별거아닌데 생각보다 위아래 두개의 속도, 메모리차가 많이났다.

중간에 더하기하는건 String+String이고 append하는건 버퍼에 담는방식인건가? 싶기도하다. 확인은 안해봤다.

300ms / 400ms, 25000KB / 20000KB

sb.append(a-- + "

");

from http://sieghart.tistory.com/43 by ccl(A) rewrite - 2021-09-10 18:01:01