CF498C.Array and Operations

提高+/省选-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

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: 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.

你在一张纸上写下了由 nn 个正整数组成的数组 a[1], a[2], …, a[n]a[1],\ a[2],\ \dots,\ a[n],以及 mm 个“好”整数对 (i1, j1), (i2, j2), …, (im, jm)(i_1,\ j_1),\ (i_2,\ j_2),\ \dots,\ (i_m,\ j_m)。每个“好”对 (ik, jk)(i_k,\ j_k) 均满足如下条件:ik+jki_k + j_k 为奇数,且 1≤ik<jk≤n1 \le i_k < j_k \le n。

在一次操作中,你可以执行以下一系列动作:

  • 选取一个“好”对 (ik, jk)(i_k,\ j_k) 及某个整数 vv(其中 v>1v > 1),使得 vv 同时整除 a[ik]a[i_k] 和 a[jk]a[j_k];
  • 将这两个数同时除以 vv,即执行赋值操作:
    和
    。

试确定:对给定数组最多能顺序执行多少次上述操作。注意,在所述操作中,同一对“好”对可被多次使用。

输入格式

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] ≤ 109) — 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.

第一行包含两个用空格分隔的整数 nn、mm(2 ≤ n ≤ 1002 \leq n \leq 100,1 ≤ m ≤ 1001 \leq m \leq 100)。

第二行包含 nn 个用空格分隔的整数 a[1], a[2], …, a[n]a[1],\,a[2],\,\dots,\,a[n](1 ≤ a[i] ≤ 1091 \leq a[i] \leq 10^9)—— 表示数组的描述。

接下来的 mm 行描述了“好对”。第 kk 行包含两个用空格分隔的整数 iki_k、jkj_k(1 ≤ ik < jk ≤ n1 \leq i_k < j_k \leq n,且 ik + jki_k + j_k 为奇数)。

保证所有“好对”互不相同。

输出格式

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

输入解题思路,AI测评打分。不知道怎么写?

首页