CF1744E1.Divisible Numbers (easy version)

普及/提高-

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

This is an easy version of the problem. The only difference between an easy and a hard version is the constraints on aa, bb, cc and dd.

You are given 44 positive integers aa, bb, cc, dd with a<ca \lt c and b<db \lt d. Find any pair of numbers xx and yy that satisfies the following conditions:

  • a<x≤ca \lt x \leq c, b<y≤db \lt y \leq d,
  • x⋅yx \cdot y is divisible by a⋅ba \cdot b.

Note that required xx and yy may not exist.

这是一个该问题的简单版本。简单版本与困难版本的唯一区别在于对 aa、bb、cc 和 dd 的约束条件不同。

给定 44 个正整数 aa、bb、cc、dd,满足 a<ca \lt c 且 b<db \lt d。请找出任意一对数 xx 和 yy,使其满足以下条件:

  • a<x≤ca \lt x \leq c,b<y≤db \lt y \leq d,
  • x⋅yx \cdot y 能被 a⋅ba \cdot b 整除。

注意:满足要求的 xx 和 yy 可能不存在。

输入格式

The first line of the input contains a single integer tt (1≤t≤10(1 \leq t \leq 10), the number of test cases.

The descriptions of the test cases follow.

The only line of each test case contains four integers aa, bb, cc and dd (1≤a<c≤1051 \leq a \lt c \leq 10^5, 1≤b<d≤1051 \leq b \lt d \leq 10^5).

输入的第一行包含一个整数 tt(1≤t≤101 \leq t \leq 10),表示测试用例的数量。

接下来是各测试用例的描述。

每个测试用例仅一行,包含四个整数 aa、bb、cc 和 dd(1≤a<c≤1051 \leq a \lt c \leq 10^5,1≤b<d≤1051 \leq b \lt d \leq 10^5)。

输出格式

For each test case print a pair of numbers a<x≤ca \lt x \leq c and b<y≤db \lt y \leq d such that x⋅yx \cdot y is divisible by a⋅ba \cdot b. If there are multiple answers, print any of them. If there is no such pair of numbers, then print -1 -1.

对每个测试用例,输出一对数 a<x≤ca \lt x \leq c 和 b<y≤db \lt y \leq d,使得 x⋅yx \cdot y 能被 a⋅ba \cdot b 整除。若存在多组解,输出任意一组即可。若不存在满足条件的数对,则输出 -1 -1。

输入输出样例

  • 输入#1

    5
    1 1 2 2
    3 4 5 7
    8 9 15 18
    12 21 14 24
    36 60 48 66

    输出#1

    2 2
    4 6
    12 12
    -1 -1
    -1 -1

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

首页