Codeforces Round 196 (Div. 1)
D
GCD Table
Codeforces
2900
原题
← CE →
翻译中…

Consider a table $*G*$ of size $*n* × *m*$ such that $*G*(*i*, *j*) = *GCD*(*i*, *j*)$ for all $1 ≤ *i* ≤ *n*, 1 ≤ *j* ≤ *m*$. $*GCD*(*a*, *b*)$ is the greatest common divisor of numbers $*a*$ and $*b*$.

翻译中…

You have a sequence of positive integer numbers $*a*_{1}, *a*_{2}, ..., *a*_{*k*}$. We say that this sequence occurs in table $*G*$ if it coincides with consecutive elements in some row, starting from some position. More formally, such numbers $1 ≤ *i* ≤ *n*$ and $1 ≤ *j* ≤ *m* - *k* + 1$ should exist that $*G*(*i*, *j* + *l* - 1) = *a*_{*l*}$ for all $1 ≤ *l* ≤ *k*$.

翻译中…

Determine if the sequence $*a*$ occurs in table $*G*$.

翻译中…

Input

翻译中…

The first line contains three space-separated integers $*n*$, $*m*$ and $*k*$ ($1 ≤ *n*, *m* ≤ 10^{12}$; $1 ≤ *k* ≤ 10000$). The second line contains $*k*$ space-separated integers $*a*_{1}, *a*_{2}, ..., *a*_{*k*}$ ($1 ≤ *a*_{*i*} ≤ 10^{12}$).

翻译中…

Output

翻译中…

Print a single word "YES", if the given sequence occurs in table $*G*$, otherwise print "NO".

翻译中…

Note

翻译中…

Sample 1. The tenth row of table $*G*$ starts from sequence {1, 2, 1, 2, 5, 2, 1, 2, 1, 10}. As you can see, elements from fifth to ninth coincide with sequence $*a*$.

翻译中…

Sample 2. This time the width of table $*G*$ equals 8. Sequence $*a*$ doesn't occur there.

翻译中…

样例

Input #1
100 100 5
5 2 1 2 1
Output #1
YES
InputCopy OutputCopy
Input #2
100 8 5
5 2 1 2 1
Output #2
NO
InputCopy OutputCopy
Input #3
100 100 7
1 2 3 4 5 6 7
Output #3
NO
InputCopy OutputCopy
题目信息
题号
338D
时间限制
1 s
内存限制
256 MB
标签
中国剩余定理
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。