program name
    implicit none
    integer(8):: a,b,c,na
    logical:: apa(0:99)
    read*, a,b,c
    apa(:) = .false.
    na = a
    do
        if (mod(na,b) == c) then
            print*, 'YES'
            stop
        else
            if (apa(mod(na,b))) then
                print*, 'NO'
                stop
            end if
            apa(mod(na,b)) = .true.
            na=na+a
        end if
    end do
end program name