CF498C.Array and Operations

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You have written on a piece of paper an array of nn positive integers a[1],a[2],...,a[n]a[1],a[2],...,a[n] and mm good pairs of integers (i1,j1),(i2,j2),...,(im,jm)(i_{1},j_{1}),(i_{2},j_{2}),...,(i_{m},j_{m}) . Each good pair (ik,jk)(i_{k},j_{k}) meets the following conditions: ik+jki_{k}+j_{k} is an odd number and 1<=ik<jk<=n1<=i_{k}<j_{k}<=n .

In one operation you can perform a sequence of actions:

  • take one of the good pairs (ik,jk)(i_{k},j_{k}) and some integer vv ( v>1v>1 ), which divides both numbers a[ik]a[i_{k}] and a[jk]a[j_{k}] ;
  • divide both numbers by vv , i. e. perform the assignments: and .

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 nn , mm ( 2<=n<=1002<=n<=100 , 1<=m<=1001<=m<=100 ).

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

The following mm lines contain the description of good pairs. The kk -th line contains two space-separated integers iki_{k} , jkj_{k} ( 1<=ik<jk<=n1<=i_{k}<j_{k}<=n , ik+jki_{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
    
首页