You are given three integers a ≤ b ≤ c a≤b≤c a≤b≤c.
In one move, you can add + 1 +1 +1 or − 1 −1 −1 to any of these integers ( i . e i.e 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 A≤B≤C A≤B≤C such that B B B is divisible by A A A and C is divisible by B B B.
You have to answer t independent test cases.
The first line of the input contains one integer t ( 1 ≤ t ≤ 100 ) t (1≤t≤100) 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 a,b a,b and c ( 1 ≤ a ≤ b ≤ c ≤ 1 0 4 ) c (1≤a≤b≤c≤10^4) c(1≤a≤b≤c≤104)
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 A≤B≤C A≤B≤C such that B B B is divisible by A A A and C C C is divisible by B B B. On the second line print any suitable triple A , B A,B A,B and C C C.
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 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
给了 a 、 b 、 c a、b、c a、b、c 三个数,现在你可以对任意一个数进行任意次数的 + 1 +1 +1 和 − 1 -1 −1
问你最少操作次数 让 b % a = 0 , c % b = 0 b\%a=0 , c\%b=0 b%a=0,c%b=0
那 a , b , c a,b,c a,b,c 改变的最大范围也就是 [ 1 , 10000 ] [1,10000] [1,10000],直接枚举就可以,但是 1000 0 3 10000^3 100003 是会超时的。这里稍微优化一下。
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const int N = 2e5 + 10;
int t;
int n, m;
int res, len, pre, now;
int a, b, c;
ll ans;
int a1, a2, a3;
int main()
{
sd(t);
while (t--)
{
sddd(a, b, c);
ans = INF;
rep(i, 1, 11000)
{
for (int j = 1; i * j <= 11000; j++)
{
for (int k = 1; i * j * k <= 11000; k++)
{
if (ans > abs(i - a) + abs(i * j - b) + abs(i * j * k - c))
{
ans = abs(i - a) + abs(i * j - b) + abs(i * j * k - c);
a1 = i, a2 = i * j, a3 = i * j * k;
}
}
}
}
pld(ans);
cout << a1 << ' ' << a2 << ' ' << a3 << '\n';
}
return 0;
}