CF1031F.Familiar Operations

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given two positive integers aa and bb. There are two possible operations:

  1. multiply one of the numbers by some prime pp;
  2. divide one of the numbers on its prime factor pp.

What is the minimum number of operations required to obtain two integers having the same number of divisors? You are given several such pairs, you need to find the answer for each of them.

给你两个正整数 aa 和 bb。有两种可能的操作:

  1. 将其中一个数乘以某个素数 pp;
  2. 将其中一个数除以其一个素因子 pp。

最少需要多少次操作,才能使这两个整数具有相同数量的正约数?你将收到多组这样的数对,需对每组数对分别求出答案。

输入格式

The first line contains a single integer tt (1≤t≤1051 \le t \le 10^5) — the number of pairs of integers for which you are to find the answer.

Each of the next tt lines contain two integers aia_i and bib_i (1≤ai,bi≤1061 \le a_i, b_i \le 10^6).

第一行包含一个整数 tt(1≤t≤1051 \le t \le 10^5)—— 表示需要求解答案的整数对的数量。

接下来的 tt 行中,每行包含两个整数 aia_i 和 bib_i(1≤ai,bi≤1061 \le a_i, b_i \le 10^6)。

输出格式

Output tt lines — the ii-th of them should contain the answer for the pair aia_i, bib_i.

输出 tt 行——第 ii 行应包含对数 (ai,bi)(a_i, b_i) 的答案。

输入输出样例

  • 输入#1

    8
    9 10
    100 17
    220 70
    17 19
    4 18
    32 20
    100 32
    224 385

    输出#1

    1
    3
    1
    0
    1
    0
    1
    1

说明/提示

These are the numbers with equal number of divisors, which are optimal to obtain in the sample test case:

  • (27,10)(27, 10), 4 divisors
  • (100,1156)(100, 1156), 9 divisors
  • (220,140)(220, 140), 12 divisors
  • (17,19)(17, 19), 2 divisors
  • (12,18)(12, 18), 6 divisors
  • (50,32)(50, 32), 6 divisors
  • (224,1925)(224, 1925), 12 divisors

Note that there can be several optimal pairs of numbers.

这些是在样例测试用例中能够得到的、具有相同约数个数的最优数对:

  • (27,10)(27, 10),4 个约数
  • (100,1156)(100, 1156),9 个约数
  • (220,140)(220, 140),12 个约数
  • (17,19)(17, 19),2 个约数
  • (12,18)(12, 18),6 个约数
  • (50,32)(50, 32),6 个约数
  • (224,1925)(224, 1925),12 个约数

注意:可能存在多个最优数对。

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

首页