跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F2341. GCD Table

  • ID: 2347
  • 传统题
  • 2000ms
  • 256MiB
  • 尝试: 0
  • AC · 已通过: 0
  • 教学难度:挑战
  • 上传者:
  • 中国剩余定理
  • 数学
  • 数论
  • 挑战
  • 难度
  • 共享题库
  • Codeforces
  • 英文题面
  • 题目来源
  • 题面语言

GCD Table

题目描述

D. GCD Table
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 a1,a2,...,ak. 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)=al 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≤1012; 1≤k≤10000). The second line contains k space-separated integers a1,a2,...,ak (1≤ai≤1012).

Output

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

Examples
Input
100 100 5
5 2 1 2 1
Output
YES
Input
100 8 5
5 2 1 2 1
Output
NO
Input
100 100 7
1 2 3 4 5 6 7
Output
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.


题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 1963 题。保留原作者与原赛事署名。