#abc259e. E - LCM on Whiteboard

E - LCM on Whiteboard

Score : 500500 points

问题描述

在一块白板上有 NN 个整数 a1,,aNa_1,\ldots,a_N

这里,每个整数 aia_i 可以表示为 $a_i = p_{i,1}^{e_{i,1}} \times \ldots \times p_{i,m_i}^{e_{i,m_i}}$,其中使用了 mim_i 个素数 pi,1<<pi,mip_{i,1} < \ldots < p_{i,m_i} 和正整数 ei,1,,ei,mie_{i,1},\ldots,e_{i,m_i}

你将从这 NN 个整数中选择一个替换成 11。求替换后 NN 个整数的最小公倍数可能取到的不同数值个数。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There are NN integers a1,,aNa_1,\ldots,a_N written on a whiteboard.
Here, aia_i can be represented as $a_i = p_{i,1}^{e_{i,1}} \times \ldots \times p_{i,m_i}^{e_{i,m_i}}$ using mim_i prime numbers pi,1<<pi,mip_{i,1} \lt \ldots \lt p_{i,m_i} and positive integers ei,1,,ei,mie_{i,1},\ldots,e_{i,m_i}.
You will choose one of the NN integers to replace it with 11.
Find the number of values that can be the least common multiple of the NN integers after the replacement.

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • 1mi1 \leq m_i
  • mi2×105\sum{m_i} \leq 2 \times 10^5
  • 2pi,1<<pi,mi1092 \leq p_{i,1} \lt \ldots \lt p_{i,m_i} \leq 10^9
  • pi,jp_{i,j} is prime.
  • 1ei,j1091 \leq e_{i,j} \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

m1m_1

p1,1p_{1,1} e1,1e_{1,1}

\vdots

p1,m1p_{1,m_1} e1,m1e_{1,m_1}

m2m_2

p2,1p_{2,1} e2,1e_{2,1}

\vdots

p2,m2p_{2,m_2} e2,m2e_{2,m_2}

\vdots

mNm_N

pN,1p_{N,1} eN,1e_{N,1}

\vdots

pN,mNp_{N,m_N} eN,mNe_{N,m_N}

Output

Print the answer.

Sample Input 1

4
1
7 2
2
2 2
5 1
1
5 1
2
2 1
7 1

Sample Output 1

3

The integers on the whiteboard are $a_1 =7^2=49, a_2=2^2 \times 5^1 = 20, a_3 = 5^1 = 5, a_4=2^1 \times 7^1 = 14$.
If you replace a1a_1 with 11, the integers on the whiteboard become 1,20,5,141,20,5,14, whose least common multiple is 140140.
If you replace a2a_2 with 11, the integers on the whiteboard become 49,1,5,1449,1,5,14, whose least common multiple is 490490.
If you replace a3a_3 with 11, the integers on the whiteboard become 49,20,1,1449,20,1,14, whose least common multiple is 980980.
If you replace a4a_4 with 11, the integers on the whiteboard become 49,20,5,149,20,5,1, whose least common multiple is 980980.
Therefore, the least common multiple of the NN integers after the replacement can be 140140, 490490, or 980980, so the answer is 33.

Sample Input 2

1
1
998244353 1000000000

Sample Output 2

1

There may be enormous integers on the whiteboard.

update @ 2024/3/10 10:59:50