CF819C.Mister B and Beacons on Field

省选/NOI-

通过率:0%

时间限制:5.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Mister B has a house in the middle of a giant plain field, which attracted aliens life. For convenience, aliens specified the Cartesian coordinate system on the field in such a way that Mister B's house has coordinates (0, 0). After that they sent three beacons to the field, but something went wrong. One beacon was completely destroyed, while the other two landed in positions with coordinates (m, 0) and (0, n), respectively, but shut down.

Mister B was interested in this devices, so he decided to take them home. He came to the first beacon, placed at (m, 0), lifted it up and carried the beacon home choosing the shortest path. After that he came to the other beacon, placed at (0, n), and also carried it home choosing the shortest path. When first beacon was lifted up, the navigation system of the beacons was activated.

Partially destroyed navigation system started to work in following way.

At time moments when both survived beacons are at points with integer coordinates the system tries to find a location for the third beacon. It succeeds if and only if there is a point with integer coordinates such that the area of the triangle formed by the two survived beacons and this point is equal to s. In this case the system sends a packet of information with beacon positions to aliens, otherwise it doesn't.

Compute how many packets of information system sent while Mister B was moving the beacons.

米斯特·B 的房子位于一片广阔平原的正中央,这引起了外星生命的注意。为方便起见,外星人在这片平原上建立了笛卡尔坐标系,使得米斯特·B 的房子位于坐标原点 (0, 0)(0,\,0)。随后,他们向这片平原发射了三枚信标,但出了意外:其中一枚信标完全损毁,另外两枚则分别降落在坐标为 (m, 0)(m,\,0) 和 (0, n)(0,\,n) 的位置,但随即关闭。

米斯特·B 对这些装置很感兴趣,于是决定将它们带回家。他先前往位于 (m, 0)(m,\,0) 的第一枚信标,将其拾起,并选择最短路径将其运回住所。接着,他又前往位于 (0, n)(0,\,n) 的第二枚信标,同样选择最短路径将其运回住所。当第一枚信标被拾起时,信标的导航系统被激活。

这个部分损毁的导航系统以如下方式运行:

在任意时刻,若两枚幸存信标均位于整数坐标点上,则该系统尝试为第三枚信标确定一个位置。当且仅当存在某个整数坐标点,使得由这两枚幸存信标与该点所构成的三角形面积恰好等于 ss 时,系统才能成功定位;此时系统便向外星人发送一份包含两枚信标当前位置的信息包;否则不发送。

请计算:在米斯特·B 运送这两枚信标的过程中,该系统共发送了多少份信息包?

输入格式

The first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. The next 3·t lines describe t test cases.

Every test case is described in three lines as follows. Note that each parameter is given as a product of three factors.

The first line of a test case contains three space-separated integers: _n_1, _n_2, _n_3 (1 ≤ n__i ≤ 106) such that n = _n_1·_n_2·_n_3.

The second line contains three space-separated integers: _m_1, _m_2, _m_3 (1 ≤ m__i ≤ 106) such that m = _m_1·_m_2·_m_3.

The third line contains three space-separated integers: _s_1, _s_2, _s_3 (1 ≤ s__i ≤ 106) such that s = _s_1·_s_2·_s_3.

Note that for hacks only tests with t = 1 allowed.

第一行包含一个整数 tt(1≤t≤10001 \leq t \leq 1000)—— 表示测试用例的数量。接下来的 3⋅t3\cdot t 行描述了 tt 个测试用例。

每个测试用例由三行描述,如下所示。注意:每个参数均以三个因子的乘积形式给出。

测试用例的第一行包含三个用空格分隔的整数:n1n_1、n2n_2、n3n_3(1≤ni≤1061 \leq n_i \leq 10^6),满足 n=n1⋅n2⋅n3n = n_1 \cdot n_2 \cdot n_3。

测试用例的第二行包含三个用空格分隔的整数:m1m_1、m2m_2、m3m_3(1≤mi≤1061 \leq m_i \leq 10^6),满足 m=m1⋅m2⋅m3m = m_1 \cdot m_2 \cdot m_3。

测试用例的第三行包含三个用空格分隔的整数:s1s_1、s2s_2、s3s_3(1≤si≤1061 \leq s_i \leq 10^6),满足 s=s1⋅s2⋅s3s = s_1 \cdot s_2 \cdot s_3。

注意:对于 hack,仅允许使用 t=1t = 1 的测试用例。

输出格式

Print t integers one per line — the answers for each test.

每行输出一个整数——每个测试用例的答案。

输入输出样例

  • 输入#1

    3
    2 1 1
    2 1 1
    1 1 3
    1 5 1
    2 2 1
    1 1 2
    10 6 18
    2 103 2
    13 1 13

    输出#1

    4
    7
    171

说明/提示

First test case contains the following beacon positions: (2, 0) and (0, 2), s = 3. The following packets could be sent: ((2, 0), (0, 2), ( - 1, 0)), ((1, 0), (0, 2), (4, 0)), ((0, 0), (0, 2), (3, 1)), ((0, 0), (0, 1), ( - 6, 0)), where (_b_1, _b_2, p) has next description: _b_1 — first beacon position, _b_2 — second beacon position, p — some generated point.

Second test case contains the following beacon initial positions: (4, 0) and (0, 5), s = 2. The following packets could be sent: ((4, 0), (0, 5), (0, 4)), ((3, 0), (0, 5), (2, 3)), ((2, 0), (0, 5), (2, 2)), ((1, 0), (0, 5), (1, 4)), ((0, 0), (0, 4), (0,  - 1)), ((0, 0), (0, 2), (2, 0)), ((0, 0), (0, 1), (4, 0)).

第一个测试用例包含以下信标位置:(2, 0)(2,\,0) 和 (0, 2)(0,\,2),s=3s = 3。以下数据包可以被发送:((2, 0), (0, 2), (−1, 0))((2,\,0),\,(0,\,2),\,(-1,\,0))、((1, 0), (0, 2), (4, 0))((1,\,0),\,(0,\,2),\,(4,\,0))、((0, 0), (0, 2), (3, 1))((0,\,0),\,(0,\,2),\,(3,\,1))、((0, 0), (0, 1), (−6, 0))((0,\,0),\,(0,\,1),\,(-6,\,0)),其中 (b1, b2, p)(b_1,\,b_2,\,p) 的含义如下:b1b_1 表示第一个信标的位置,b2b_2 表示第二个信标的位置,pp 表示某个生成的点。

第二个测试用例包含以下信标初始位置:(4, 0)(4,\,0) 和 (0, 5)(0,\,5),s=2s = 2。以下数据包可以被发送:((4, 0), (0, 5), (0, 4))((4,\,0),\,(0,\,5),\,(0,\,4))、((3, 0), (0, 5), (2, 3))((3,\,0),\,(0,\,5),\,(2,\,3))、((2, 0), (0, 5), (2, 2))((2,\,0),\,(0,\,5),\,(2,\,2))、((1, 0), (0, 5), (1, 4))((1,\,0),\,(0,\,5),\,(1,\,4))、((0, 0), (0, 4), (0, −1))((0,\,0),\,(0,\,4),\,(0,\,-1))、((0, 0), (0, 2), (2, 0))((0,\,0),\,(0,\,2),\,(2,\,0))、((0, 0), (0, 1), (4, 0))((0,\,0),\,(0,\,1),\,(4,\,0))。

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

首页