D. Three Integers
暴力
暴力的优美!!!!!!!
一针见血的解法,我们要洞悉复杂度!!!
#include<iostream> using namespace std; int main(){ int t;cin>>t; while(t--){ int a,b,c; cin>>a>>b>>c; int a1,a2,a3; int ans = 1e5; for (int i=1;i<=10000;++i) for (int j=i;j<=20000;j+=i) for (int k=j;k<=40000;k+=j) if (abs(i-a)+abs(j-b)+abs(k-c)<ans) ans=abs(i-a)+abs(j-b)+abs(k-c),a1=i,a2=j,a3=k; cout<<ans<<endl<<a1<<" "<<a2<<" "<<a3<<endl; } }