CF1584A.Mathematical Addition

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Ivan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form:

  • You are given two positive integers uu and vv, find any pair of integers (not necessarily positive) xx, yy, such that: $$\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.$$
  • The solution x=0x = 0, y=0y = 0 is forbidden, so you should find any solution with (x,y)≠(0,0)(x, y) \neq (0, 0).

Please help Ivan to solve some equations of this form.

伊万决定为求解整数方程的测试做准备。他注意到测试中的所有题目都具有如下形式:

  • 给定两个正整数 uu 和 vv,找出任意一对整数(不一定是正整数)xx、yy,使得:

    xu+yv=x+yu+v.\frac{x}{u} + \frac{y}{v} = \frac{x + y}{u + v}.

  • 解 x=0x = 0、y=0y = 0 是被禁止的,因此你需要找出满足 (x,y)≠(0,0)(x, y) \neq (0, 0) 的任意一组解。

请帮助伊万求解若干此类方程。

输入格式

The first line contains a single integer tt (1≤t≤1031 \leq t \leq 10^3) — the number of test cases. The next lines contain descriptions of test cases.

The only line of each test case contains two integers uu and vv (1≤u,v≤1091 \leq u, v \leq 10^9) — the parameters of the equation.

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

每个测试用例仅一行,包含两个整数 uu 和 vv(1≤u,v≤1091 \leq u, v \leq 10^9),表示该方程的参数。

输出格式

For each test case print two integers xx, yy — a possible solution to the equation. It should be satisfied that −1018≤x,y≤1018-10^{18} \leq x, y \leq 10^{18} and (x,y)≠(0,0)(x, y) \neq (0, 0).

We can show that an answer always exists. If there are multiple possible solutions you can print any.

对每个测试用例,输出两个整数 xx、yy —— 该方程的一个可能解。需满足 −1018≤x,y≤1018-10^{18} \leq x, y \leq 10^{18} 且 (x,y)≠(0,0)(x, y) \neq (0, 0)。

可以证明解一定存在。若存在多个可能的解,输出任意一个即可。

输入输出样例

  • 输入#1

    4
    1 1
    2 3
    3 5
    6 9

    输出#1

    -1 1
    -4 9
    -18 50
    -4 9

说明/提示

In the first test case: −11+11=0=−1+11+1\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}.

In the second test case: −42+93=1=−4+92+3\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}.

In the third test case: −183+505=4=−18+503+5\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}.

In the fourth test case: −46+99=13=−4+96+9\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}.

第一个测试用例:−11+11=0=−1+11+1\frac{-1}{1} + \frac{1}{1} = 0 = \frac{-1 + 1}{1 + 1}。

第二个测试用例:−42+93=1=−4+92+3\frac{-4}{2} + \frac{9}{3} = 1 = \frac{-4 + 9}{2 + 3}。

第三个测试用例:−183+505=4=−18+503+5\frac{-18}{3} + \frac{50}{5} = 4 = \frac{-18 + 50}{3 + 5}。

第四个测试用例:−46+99=13=−4+96+9\frac{-4}{6} + \frac{9}{9} = \frac{1}{3} = \frac{-4 + 9}{6 + 9}。

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

首页