Three Integers
枚举(a,b)
处理 (c) 最小上界 (cc = cb * (c / cb) + 1 * cb;)
最大上界(cc = cb * (c / cb) + 0 * cb;)
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define endl '
'
typedef double db;
typedef long long LL;
const db EPS = 1e-9;
const int N = 2e5 + 100,INF = 1 << 31 - 1;
int main() {
ios::sync_with_stdio(0),cout.tie(0),cin.tie(0);
int t,a,b,c;
cin >> t;
while(t --) {
cin >> a >> b >> c;
int x,y,z,ans = INF;
for(int ca = 1;ca <= 2 * a; ++ca) {
for(int cb = ca;cb <= 2 * b; cb += ca) {
for(int k = 0;k < 2; ++k) {
int cc = cb * (c / cb) + k * cb;
int ts = abs(a - ca) + abs(b - cb) + abs(c - cc);
if(ts < ans) {
ans = ts;
x = ca,y = cb,z = cc;
}
}
}
}
cout << ans << endl << x <<' ' << y <<' ' << z << endl;
}
return 0;
}