You are given three integers a≤b≤ca≤b≤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≤B≤C such that BB is divisible by AA and CC is divisible by BB .

You have to answer tt independent test cases.

Input

The first line of the input contains one integer tt (1≤t≤1001≤t≤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≤a≤b≤c≤104 ).

Output

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≤B≤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 .

Example
Input

 
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
Output

 
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
一开始想了半天再加上题目的rating1900+math的标签就以为是数论不敢做了,后来看大佬说是暴力...枚举有两种方式,一种是直接枚举A,B,C(注意里面两重循环 for(int j = i; j <= 15000; j += i)for(int k = j; k <= 15000; k += j)不要写++;一种是枚举倍数 for(k=1;i*j*k<=20000;k++)for(k=1;i*j*k<=20000;k++)。玄学范围看着枚举就行,看似O(n^3)实际上有了剪枝是到不了的。Div3别想的太复杂。
#include <bits/stdc++.h>
int a,b,c;
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
scanf("%d%d%d",&a,&b,&c);
int A,B,C,i,j,k; int mmin=;
int tot;
for(i=;i<=;i++)
{
for(j=;i*j<=;j++)
{
for(k=;i*j*k<=;k++)
{
tot=abs(a-i)+abs(b-j*i)+abs(c-i*j*k);
if(tot<mmin)
{
mmin=tot;
A=i;
B=i*j;
C=i*j*k;
}
}
}
}
cout<<mmin<<endl;
printf("%d %d %d\n",A,B,C);
}
}

最新文章

  1. 【转载】10 个实用技巧,让 Finder 带你飞
  2. Jquery事件:鼠标移入移出(mouseenter,mouseleave)
  3. Java Web学习路线
  4. new与malloc
  5. hdu 4046 2011北京赛区网络赛G 线段树 ***
  6. E2 2014.08.05 更新日志
  7. Android线程消息通信(二)
  8. 精华阅读第 9 期 |滴滴出行 iOS 客户端架构演进之路
  9. webSocket vnc rfb
  10. [数据结构]Splay简介
  11. 基于swift MKMapkit 开发的地图定位导航
  12. 如何统计iOS产品不同渠道的下载量?
  13. 跨域的另一种解决方案CORS(CrossOrigin Resource Sharing)跨域资源共享
  14. Elasticsearch: 权威指南 &#187; 深入搜索 &#187; 多字段搜索 &#187; 多数字段 good
  15. (转)常用的 TCP KeepAlive 参数
  16. [osgearth][原]仿照谷歌,修改oe漫游器中focal(视角切换)功能
  17. Macaca之Android原理浅析
  18. 【BZOJ】【1968】【AHOI2005】COMMON 约数研究
  19. react分享
  20. BZOJ1066_蜥蜴_KEY

热门文章

  1. ubuntu set up 3 - cuda
  2. 在bootstrap的column中的formatter里不能传递row参数吗?
  3. grep/sed/awk命令查看指定时间段的日志
  4. centos7 防火墙的操作
  5. 143. 最大异或对(Trie树存整数+二进制)
  6. leetcode全部滑动窗口题目总结C++写法(完结)
  7. springboot11(springboot-redis)
  8. Java中boolean类型到底占用多少字节(转载)
  9. ASP.NET + MVC5 入门完整教程四---MVC 中使用扩展方法
  10. input标签中的id和name的区别