CF1311D.Three Integers

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given three integers a≤b≤ca \le b \le c.

In one move, you can add +1+1 or −1-1 to any of these integers (i.e. increase or decrease any number by one). You can perform such operation any (possibly, zero) number of times, you can even perform this operation several times with one number. Note that you cannot make non-positive numbers using such operations.

You have to perform the minimum number of such operations in order to obtain three integers A≤B≤CA \le B \le C such that BB is divisible by AA and CC is divisible by BB.

You have to answer tt independent test cases.

给你三个整数 a≤b≤ca \le b \le c。

每次操作中,你可以对其中任意一个整数加 +1+1 或减 −1-1(即对任一数字增加或减少 1)。你可以执行任意次(可能为零次)此类操作,甚至可以对同一个数字执行多次操作。注意:你不能通过此类操作得到非正整数。

你需要执行最少次数的操作,使得最终得到三个整数 A≤B≤CA \le B \le C,满足 BB 能被 AA 整除,且 CC 能被 BB 整除。

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

输入格式

The first line of the input contains one integer tt (1≤t≤1001 \le t \le 100) — the number of test cases.

The next tt lines describe test cases. Each test case is given on a separate line as three space-separated integers a,ba, b and cc (1≤a≤b≤c≤1041 \le a \le b \le c \le 10^4).

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

接下来的 tt 行描述了各个测试用例。每个测试用例占一行,由三个以空格分隔的整数 aa、bb 和 cc 组成(1≤a≤b≤c≤1041 \le a \le b \le c \le 10^4)。

输出格式

For each test case, print the answer. In the first line print resres — the minimum number of operations you have to perform to obtain three integers A≤B≤CA \le B \le C such that BB is divisible by AA and CC is divisible by BB. On the second line print any suitable triple A,BA, B and CC.

对于每个测试用例,请输出答案。第一行输出 resres —— 为得到满足 A≤B≤CA \le B \le C、且 BB 能被 AA 整除、CC 能被 BB 整除的三个整数,所需执行的最少操作次数。第二行输出任意一组满足条件的三元组 A,BA, B 和 CC。

输入输出样例

  • 输入#1

    8
    1 2 3
    123 321 456
    5 10 15
    15 18 21
    100 100 101
    1 22 29
    3 19 38
    6 30 46

    输出#1

    1
    1 1 3
    102
    114 228 456
    4
    4 8 16
    6
    18 18 18
    1
    100 100 100
    7
    1 22 22
    2
    1 19 38
    8
    6 24 48

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

首页