페이지

1592번: 영식이와 친구들

https://www.acmicpc.net/problem/1592


#include<stdio.h>
int data[1000], N, M, L, pos, ans;
int main()
{
    scanf("%d%d%d", &N, &M, &L);
    while (1)
    {
        data[pos]++;
        if (data[pos] == M)
        {
            break;
        }
        ans++;
        if (data[pos] % 2 == 1)
        {
            pos = (pos + N - L) % N;
        }
        else
        {
            pos = (pos + L) % N;
        }
    }
    printf("%d", ans);
    return 0;
}

댓글 없음 :

댓글 쓰기