In one move, you can add +1 or −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≤C such that B is divisible by A and C is divisible by B.

You have to answer t independent test cases.

Input

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

The next t lines describe test cases. Each test case is given on a separate line as three space-separated integers a,b and c (1≤a≤b≤c≤104).

Output

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

Example

inputCopy

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

outputCopy

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

纯暴力枚举(有点技巧,小剪枝)

#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e15 + 5;
int main()
{
int t;
cin >> t;
while (t--)
{
long long a, b, c, a1, b1, c1;
scanf("%lld %lld %lld", &a, &b, &c);
long long cnt = maxn;
for (long long k = 1; k <=5*c; k++)
{
for (long long i = 1; i*k<=5*c; i++)
for (long long j = 1;i*k* j <=5*c ; j++)
{ long long temp = abs(k - a) + abs(i * k - b) + abs(j * i * k - c);
if (temp < cnt)
{
cnt = temp;
a1 = k;
b1 = i * k;
c1 = i * j * k;
}
// else
// break;
}
}
printf("%lld\n", cnt);
printf("%lld %lld %lld\n", a1, b1, c1);
}
}

最新文章

  1. 【软件工具】Driver Booster3永久激活法
  2. Unity导出xcode后自动化导入第三方SDK
  3. Dockerfile指令
  4. BootStrap安装
  5. HDOJ 3555 Bomb
  6. LeetCode30 Substring with Concatenation of All Words
  7. chrome浏览器无法设置打开特定网页
  8. SimpleDateFormat 的性能和线程安全性
  9. 【UVA】1449-Dominating Patterns(AC自己主动机)
  10. hdu 5664 Lady CA and the graph(树的点分治+容斥)
  11. Leetcode:Two Sum
  12. java 抽象
  13. Windows10常用快捷键
  14. 响应式web布局设计实战总结教程
  15. RECON-NG
  16. ASP.NET实现二维码(QRCode)的创建和读取
  17. Docker数据管理(数据卷&amp;数据卷容器)
  18. 为什么Java7开始在数字中使用下划线
  19. apache 伪静态 .htaccess
  20. jquery each遍历判断返回false方法

热门文章

  1. 20 java 基础回顾--中阶引入
  2. 9.1 ArrayList(集合)的使用,与array(数组)的对比
  3. matplotlib Bbox类
  4. AJ学IOS 之二维码学习,快速打开相机读取二维码
  5. FreeRTOS操作系统工程建立和操作系统的概念
  6. stand up meeting 11/25/2015 暨sprint2总结
  7. F - Select Half dp
  8. CodeForces - 913C (贪心)
  9. 利用Putty建立SSH的tunnels访问内网资源
  10. Matlab学习-(1)