题库练习 Array and Operations
← 上一题 下一题 →

A9700 | Array and Operations

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You have written on a piece of paper an array of $n$ positive integers $a[1],a[2],...,a[n]$ and $m$ good pairs of integers $(i_{1},j_{1}),(i_{2},j_{2}),...,(i_{m},j_{m})$ . Each good pair $(i_{k},j_{k})$ meets the following conditions: $i_{k}+j_{k}$ is an odd number and $1<=i_{k}<j_{k}<=n$ .

In one operation you can perform a sequence of actions:

- take one of the good pairs $(i_{k},j_{k})$ and some integer $v$ ( $v>1$ ), which divides both numbers $a[i_{k}]$ and $a[j_{k}]$ ;
- divide both numbers by $v$ , i. e. perform the assignments: ![](/uploads/luogu/CF498C/20c1f57520e06ca3d1c3b4ad7151b71ff8d2bae7_f0e1478b4928.png) and ![](/uploads/acgo/image/5f286e7111f70573_78972cdbc3a5.jpeg).

Determine the maximum number of operations you can sequentially perform on the given array. Note that one pair may be used several times in the described operations.

输入格式

The first line contains two space-separated integers $n$ , $m$ ( $2<=n<=100$ , $1<=m<=100$ ).

The second line contains $n$ space-separated integers $a[1],a[2],...,a[n]$ ( $1<=a[i]<=10^{9}$ ) — the description of the array.

The following $m$ lines contain the description of good pairs. The $k$ -th line contains two space-separated integers $i_{k}$ , $j_{k}$ ( $1<=i_{k}<j_{k}<=n$ , $i_{k}+j_{k}$ is an odd number).

It is guaranteed that all the good pairs are distinct.

输出格式

Output the answer for the problem.

输入输出样例

输入 #1
3 2
8 3 8
1 2
2 3
输出 #1
0
输入 #2
3 2
8 12 8
1 2
2 3
输出 #2
2
C++ 编辑器
输入
输出