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);
}
}

Codeforces Round #624 (Div. 3) D. Three Integers的更多相关文章

  1. Codeforces Round #624 (Div. 3)(题解)

    Codeforces Round #624 (Div.3) 题目地址:https://codeforces.ml/contest/1311 B题:WeirdSort 题意:给出含有n个元素的数组a,和 ...

  2. Codeforces Round #624 (Div. 3) C. Perform the Combo(前缀和)

    You want to perform the combo on your opponent in one popular fighting game. The combo is the string ...

  3. Codeforces Round #624 (Div. 3) F. Moving Points 题解

    第一次写博客 ,请多指教! 翻了翻前面的题解发现都是用树状数组来做,这里更新一个 线段树+离散化的做法: 其实这道题是没有必要用线段树的,树状数组就能够解决.但是个人感觉把线段树用熟了会比树状数组更有 ...

  4. Codeforces Round #624 (Div. 3) B. WeirdSort(排序)

    output standard output You are given an array aa of length nn . You are also given a set of distinct ...

  5. Codeforces Round #624 (Div. 3) A. Add Odd or Subtract Even(水题)

    You are given two positive integers aa and bb . In one move, you can change aa in the following way: ...

  6. Codeforces Round #624 (Div. 3)(题解)

    A. Add Odd or Subtract Even 思路: 相同直接为0,如果两数相差为偶数就为2,奇数就为1 #include<iostream> #include<algor ...

  7. 详细讲解Codeforces Round #624 (Div. 3) E. Construct the Binary Tree(构造二叉树)

    题意:给定节点数n和所有节点的深度总和d,问能否构造出这样的二叉树.能,则输出“YES”,并且输出n-1个节点的父节点(节点1为根节点). 题解:n个节点构成的二叉树中,完全(满)二叉树的深度总和最小 ...

  8. 详细讲解Codeforces Round #624 (Div. 3) F. Moving Points

    题意:给定n个点的初始坐标x和速度v(保证n个点的初始坐标互不相同), d(i,j)是第i个和第j个点之间任意某个时刻的最小距离,求出n个点中任意一对点的d(i,j)的总和. 题解:可以理解,两个点中 ...

  9. Codeforces Round #624 (Div. 3)

    A.题意:通过加奇数减偶数的操作从a到b最少需要几步 签到题 #include <algorithm> #include <iostream> #include <cst ...

随机推荐

  1. 【你不知道的javaScript 上卷 笔记3】javaScript中的声明提升表现

    console.log( a ); var a = 2; 执行输出undefined a = 2; var a; console.log( a ); 执行输出2 说明:javaScript 运行时在编 ...

  2. eclipse unable to start within 45 seconds

    在eclipse4.8.2中运行tomcat8.5项目时,提示出错: Server Tomcat v8.0 Server at localhost was unable to start within ...

  3. ++i、i++、+=、-=的区别

    要分清这个区别,先要掌握赋值的顺序,赋值语句是从右往左执行的, 计算的顺序从左至右. 那么++i第一步是把自身i+1后才赋值给自身,即先加后赋值. i++第一步是先把自身赋值给自身,即先赋值后再加减. ...

  4. unity中添加音量控制的一些步骤

    1.先确认要控制的音源(Audio Source)所使用的输出(Output),例如我这里BGM使用的是MainMixer: 2.暴露音量(Volume)参数,让脚本可以控制.这里如果不暴露出来,脚本 ...

  5. 洛谷P2158 [SDOI2008]仪仗队 欧拉函数的应用

    https://www.luogu.org/problem/P2158 #include<bits/stdc++.h> #define int long long using namesp ...

  6. C++——二维数组和对象数组

    6.3 二维数组的声明和引用 声明:数据类型 标识符[常量表达式1][常量表达式2]:int a[3][4]; 表示a为整型二维数组,其中第一维有3个下标(0~2),第二维有4个下标(0~3),数组元 ...

  7. 题解 P1203 【[USACO1.1]坏掉的项链Broken Necklace】

    [USACO1.1]坏掉的项链Broken Necklace 22892 破碎的项链 方法一:很容易想到枚举断点,再分别两头找,但是要注意很多细节 #include<iostream> # ...

  8. 03-Java基础语法【 流程控制语句】

    重要知识记录: 1.流程控制 顺序结构:根据编写的顺序,从上到下进行运行. 2.判断语句 1)判断语句1--if if(判断条件){ 执行语句: } 2)判断语句2--if...else if(判断条 ...

  9. Anaconda多环境Python

    1. Create a new environment for 32bit Python 2.7: set CONDA_FORCE_32BIT=1 conda create -n py27_32 py ...

  10. crowdfunding项目03——mapper映射错误

    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'TAd ...