logo AlgoBeat OnlineJudge
登录 注册

#216229. [ICPC 2015 NAIPC] Primal Partitions

内存限制:512 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

The Math department has challenged the Computer Science department at your University to solve a difficult puzzle in Discrete Mathematics. With the pride of your Computer Science department at stake, you must solve this puzzle!

In this puzzle, you are given a sequence of positive integers. The sequence must be partitioned into consecutive contiguous regions, with at least integer in each region. After finding a partition, it is scored in a strange way. In each region, you must find the largest prime number that divides every number in that region. The Math department reminds you a prime number is an integer greater than where its only divisors are and itself. If you cannot find such a prime, your score for that region is . Your total score for the partition is the minimum over all regions.

Your task is to find the maximum possible score. The Math department will win if their score is better, so be sure to find the maximum each time!

输入格式

Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. Each input begins with a line with two space-separated integers () and (), where is the number of positive integers in the original sequence, and is the number of regions in the partition. The next line contains space-separated integers (). This is the sequence to be partitioned, in order.

输出格式

Output a single integer representing the maximum score possible partitioning the sequence of positive integers into regions.

样例

样例输入 1

5 3
10 5 4 8 3

样例输出 1

2

样例输入 2

5 3
10 11 12 13 14

样例输出 2

0