CF1379B.Dubious Cyrpto

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

Pasha loves to send strictly positive integers to his friends. Pasha cares about security, therefore when he wants to send an integer nn, he encrypts it in the following way: he picks three integers aa, bb and cc such that l≤a,b,c≤rl \leq a,b,c \leq r, and then he computes the encrypted value m=n⋅a+b−cm = n \cdot a + b - c.

Unfortunately, an adversary intercepted the values ll, rr and mm. Is it possible to recover the original values of aa, bb and cc from this information? More formally, you are asked to find any values of aa, bb and cc such that

  • aa, bb and cc are integers,
  • l≤a,b,c≤rl \leq a, b, c \leq r,
  • there exists a strictly positive integer nn, such that n⋅a+b−c=mn \cdot a + b - c = m.

帕沙喜欢向朋友发送严格正整数。帕沙注重安全性,因此当他想要发送一个整数 nn 时,他会以如下方式对其进行加密:他选取三个整数 aa、bb 和 cc,满足 l≤a,b,c≤rl \leq a,b,c \leq r,然后计算加密后的值 m=n⋅a+b−cm = n \cdot a + b - c。

不幸的是,一名攻击者截获了 ll、rr 和 mm 这三个值。能否仅凭这些信息恢复出原始的 aa、bb 和 cc?更准确地说,你需要找出任意一组满足以下条件的 aa、bb 和 cc:

  • aa、bb 和 cc 均为整数,
  • l≤a,b,c≤rl \leq a, b, c \leq r,
  • 存在某个严格正整数 nn,使得 n⋅a+b−c=mn \cdot a + b - c = m。

输入格式

The first line contains the only integer tt (1≤t≤201 \leq t \leq 20) — the number of test cases. The following tt lines describe one test case each.

Each test case consists of three integers ll, rr and mm (1≤l≤r≤500 0001 \leq l \leq r \leq 500\,000, 1≤m≤10101 \leq m \leq 10^{10}). The numbers are such that the answer to the problem exists.

第一行包含一个整数 tt(1≤t≤201 \leq t \leq 20),表示测试用例的数量。接下来的 tt 行每行描述一个测试用例。

每个测试用例包含三个整数 ll、rr 和 mm(1≤l≤r≤500 0001 \leq l \leq r \leq 500\,000,1≤m≤10101 \leq m \leq 10^{10})。所给数据保证问题有解。

输出格式

For each test case output three integers aa, bb and cc such that, l≤a,b,c≤rl \leq a, b, c \leq r and there exists a strictly positive integer nn such that n⋅a+b−c=mn \cdot a + b - c = m. It is guaranteed that there is at least one possible solution, and you can output any possible combination if there are multiple solutions.

对于每个测试用例,输出三个整数 aa、bb 和 cc,满足 l≤a,b,c≤rl \leq a, b, c \leq r,且存在一个严格正整数 nn,使得 n⋅a+b−c=mn \cdot a + b - c = m。题目保证至少存在一个可行解;若存在多个解,可输出任意一组可行解。

输入输出样例

  • 输入#1

    2
    4 6 13
    2 3 1

    输出#1

    4 6 5
    2 2 3

说明/提示

In the first example n=3n = 3 is possible, then n⋅4+6−5=13=mn \cdot 4 + 6 - 5 = 13 = m. Other possible solutions include: a=4a = 4, b=5b = 5, c=4c = 4 (when n=3n = 3); a=5a = 5, b=4b = 4, c=6c = 6 (when n=3n = 3); a=6a = 6, b=6b = 6, c=5c = 5 (when n=2n = 2); a=6a = 6, b=5b = 5, c=4c = 4 (when n=2n = 2).

In the second example the only possible case is n=1n = 1: in this case n⋅2+2−3=1=mn \cdot 2 + 2 - 3 = 1 = m. Note that, n=0n = 0 is not possible, since in that case nn is not a strictly positive integer.

在第一个例子中,n=3n = 3 是可行的,此时 n⋅4+6−5=13=mn \cdot 4 + 6 - 5 = 13 = m。其他可行解包括:a=4a = 4,b=5b = 5,c=4c = 4(当 n=3n = 3 时);a=5a = 5,b=4b = 4,c=6c = 6(当 n=3n = 3 时);a=6a = 6,b=6b = 6,c=5c = 5(当 n=2n = 2 时);a=6a = 6,b=5b = 5,c=4c = 4(当 n=2n = 2 时)。

在第二个例子中,唯一可行的情况是 n=1n = 1:此时 n⋅2+2−3=1=mn \cdot 2 + 2 - 3 = 1 = m。注意,n=0n = 0 不可行,因为此时 nn 不是严格正整数。

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

首页