[BOJ] 8981 입력숫자

Time Lapse :20min 20sec

8981.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <stdio.h>
int NUM[30];
int main() {
char i, token, N, from = 0;
scanf("%d", &N);
for (i = 0; i<N; i++) {
scanf("%d", &NUM[from]);
from = (from + NUM[from]) % N;
while (NUM[from]&&i!=N-1) from = (++from) % N;
} /* end of for */
printf("%d\n", N);
for (i = 0; i < N; ++i)
printf("%d ", NUM[i]);

return(0);
} /* end of main() */

Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/30/PS/BOJ/8981/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.