CF1612D.X-Magic Pair

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

You are given a pair of integers (a,b)(a, b) and an integer xx.

You can change the pair in two different ways:

  • set (assign) a:=∣a−b∣a := |a - b|;
  • set (assign) b:=∣a−b∣b := |a - b|,

where ∣a−b∣|a - b| is the absolute difference between aa and bb.

The pair (a,b)(a, b) is called xx-magic if xx is obtainable either as aa or as bb using only the given operations (i.e. the pair (a,b)(a, b) is xx-magic if a=xa = x or b=xb = x after some number of operations applied). You can apply the operations any number of times (even zero).

Your task is to find out if the pair (a,b)(a, b) is xx-magic or not.

You have to answer tt independent test cases.

给你一对整数 (a,b)(a, b) 和一个整数 xx。

你可以通过以下两种方式之一改变该数对:

  • 将 aa 赋值为 ∣a−b∣|a - b|(即令 a:=∣a−b∣a := |a - b|);
  • 将 bb 赋值为 ∣a−b∣|a - b|(即令 b:=∣a−b∣b := |a - b|),

其中 ∣a−b∣|a - b| 表示 aa 与 bb 的绝对差值。

若仅通过上述操作(可执行任意次,包括零次),能使 a=xa = x 或 b=xb = x 成立,则称数对 (a,b)(a, b) 是 xx-magic 的。

你的任务是判断给定的数对 (a,b)(a, b) 是否为 xx-magic。

你需要回答 tt 个相互独立的测试用例。

输入格式

The first line of the input contains one integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases. The next tt lines describe test cases.

The only line of the test case contains three integers aa, bb and xx (1≤a,b,x≤10181 \le a, b, x \le 10^{18}).

输入的第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4),表示测试用例的数量。接下来的 tt 行描述各个测试用例。

每个测试用例仅包含一行,其中为三个整数 aa、bb 和 xx(1≤a,b,x≤10181 \le a, b, x \le 10^{18})。

输出格式

For the ii-th test case, print YES if the corresponding pair (a,b)(a, b) is xx-magic and NO otherwise.

对于第 ii 个测试用例,如果对应的数对 (a,b)(a, b) 是 xx-magic 的,则输出 YES;否则输出 NO。

输入输出样例

  • 输入#1

    8
    6 9 3
    15 38 7
    18 8 8
    30 30 30
    40 50 90
    24 28 20
    365 216 52
    537037812705867558 338887693834423551 3199921013340

    输出#1

    YES
    YES
    YES
    YES
    NO
    YES
    YES
    YES

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

首页