From 25a99703400514032d02f3f723e3961de871b1dc Mon Sep 17 00:00:00 2001 From: Jinyeong Seol Date: Tue, 4 Feb 2025 00:28:41 +0900 Subject: [PATCH] =?UTF-8?q?[20250204]=20BOJ=20/=20G5=20/=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=EC=88=AB=EC=9E=90=20/=20=EC=84=A4=EC=A7=84=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...6\205\353\240\245\354\210\253\354\236\220" | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "Seol-JY/202502/04 BOJ G5 \354\236\205\353\240\245\354\210\253\354\236\220" diff --git "a/Seol-JY/202502/04 BOJ G5 \354\236\205\353\240\245\354\210\253\354\236\220" "b/Seol-JY/202502/04 BOJ G5 \354\236\205\353\240\245\354\210\253\354\236\220" new file mode 100644 index 00000000..5bc66f15 --- /dev/null +++ "b/Seol-JY/202502/04 BOJ G5 \354\236\205\353\240\245\354\210\253\354\236\220" @@ -0,0 +1,36 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + + int N = Integer.parseInt(br.readLine()); + int[] resultList = new int[N]; + int[] answerList = new int[N]; + + st = new StringTokenizer(br.readLine()); + for(int i = 0; i < N; i++) { + resultList[i] = Integer.parseInt(st.nextToken()); + } + + answerList[0] = resultList[0]; + int idx = answerList[0] % N; + + for(int i = 1; i < N; i++) { + while(answerList[idx] != 0) { + idx = (idx + 1) % N; + } + answerList[idx] = resultList[i]; + idx = (idx + resultList[i]) % N; + } + + System.out.println(N); + for(int x : answerList) { + System.out.print(x + " "); + } + } +} +```