题目链接:https://codeforces.com/contest/1311/problem/D

题意:

思路:

AC代码:

#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10000;

inline void solve()
{
    int a, b, c; cin >> a >> b >> c;
    int ansa, ansb, ansc, maxn = 100000;
    for (int i = 1; i <= MAXN * 2; ++i)
    {
        for (int j = i; j <= MAXN * 2; j += i)
        {
            for (int k = j; k <= MAXN * 2; k += j)
            {
                int temp = abs(a - i) + abs(b - j) + abs(c - k);
                if (temp < maxn)
                {
                    maxn = temp;
                    ansa = i, ansb = j, ansc = k;
                }
            }
        }
    }
    cout << maxn << endl;
    cout << ansa << " " << ansb << " " << ansc << endl;
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1; cin >> T;
    for (int i = 0; i < T; ++i) solve();
    return 0;
}
02-14 04:50