[๋ฐฑ์ค][java][10810][๊ณต ๋ฃ๊ธฐ]
n๊ฐ์ ๋ฐ๊ตฌ๋, 1๋ถํฐ n๊น์ง ์ ํ ๊ณต. m๋ฒ ๋ฃ๋๋ค. ๊ณต์ ํ๋๋ง ๋ฃ์ ์ ์๊ณ , ๊ณต์ด ์์ผ๋ฉด ๋นผ์ ๋ค์ ๋ฃ๋๋ค. ๊ทธ๋์ ์์ ์
๋ ฅ ํ๋จ 1 4 1 2 2 2 ๊ฐ ์์ ์ถ๋ ฅ์ด ๋๋ ๊ฑฐ๋ค. ์์ ๋ฃ์๋ ๊ฑฐ ๋ค ๋นผ๊ณ ์๋ก ๋ฃ์ด์. 1 4 1 : 1๋ฒ ๋ฐ๊ตฌ๋๋ถํฐ 4๋ฒ ๋ฐ๊ตฌ๋๊น์ง 1์ ๋ฃ์๋ค. 2 2 2 : 2๋ฒ ๊ณต์ 2๋ฒ ๋ฐ๊ตฌ๋์ ๋ฃ๋๋ค. import java.util.Scanner; public class Main { // 10810๊ณต ๋ฃ๊ธฐ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] res = new int[sc.nextInt()+1]; int m = sc.nextInt(); for (int a=1; a