Solution

枚举 \(a\),枚举 \(b\ s.t. a|b\),则 \(c\) 一定是 \([c/b]b\) 或 \(([c/b]+1)b\)

#include <bits/stdc++.h>
using namespace std; #define int long long
const int N = 20000; int a,b,c,T,A,B,C,ans=1e9; void upd(int i,int j,int k) {
int tmp=abs(i-A)+abs(j-B)+abs(k-C);
if(tmp<ans) {
ans=tmp;
a=i; b=j; c=k;
}
} signed main() {
ios::sync_with_stdio(false);
cin>>T;
while(T--) {
cin>>A>>B>>C;
ans=1e9;
for(int i=1;i<=N;i++) {
for(int j=i;j<=N;j+=i) {
int k;
k=(C/j)*j;
upd(i,j,k);
k+=j;
upd(i,j,k);
}
}
cout<<ans<<endl;
cout<<a<<" "<<b<<" "<<c<<endl;
}
}

[CF1311D] Three Integers - 数学的更多相关文章

  1. interesting Integers(数学暴力||数论扩展欧几里得)

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAwwAAAHwCAIAAACE0n9nAAAgAElEQVR4nOydfUBT1f/Hbw9202m0r8

  2. [LeetCode] 数学计算模拟类问题:加法,除法和幂,注意越界问题。题 剑指Offer,Pow(x, n) ,Divide Two Integers

    引言 数学计算的模拟类题目,往往是要求实现某种计算(比如两数相除),实现的过程中会有所限定,比如不允许乘法等等. 这类题目首先要注意计算过程中本身的特殊情况.比如求相除,则必须首先反映过来除数不能为0 ...

  3. Divisors of Two Integers CodeForces - 1108B (数学+思维)

    Recently you have received two positive integer numbers xx and yy. You forgot them, but you remember ...

  4. Sum of Consecutive Integers LightOJ - 1278(推公式 数学思维)

    原文地址:https://blog.csdn.net/qq_37632935/article/details/79465213 给你一个数n(n<=10^14),然后问n能用几个连续的数表示; ...

  5. [LeetCode] Sum of Two Integers 两数之和

    Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Exam ...

  6. ACM: FZU 2110 Star - 数学几何 - 水题

     FZU 2110  Star Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u  Pr ...

  7. Codeforces Round #284 (Div. 2)A B C 模拟 数学

    A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...

  8. 62. Divide Two Integers

    Divide Two Integers Divide two integers without using multiplication, division and mod operator. 思路: ...

  9. UVA 113 Power of Cryptography (数学)

    Power of Cryptography  Background Current work in cryptography involves (among other things) large p ...

随机推荐

  1. linux安装mariadb

    yum install -y mariadb-server 账号:root 密码:空 本地登录:mysql -u root -p 远程登录:mysql -h 192.168.0.1 -u root - ...

  2. selenium 多表单切换

    frame/iframe表单嵌套页面的应用.WebDrivr只能在一个页面上对元素识别与定位,对于在frame/iframe表单内嵌页面上的元素无法直接定位.这时需要使用 switch_to.fram ...

  3. HDU_1222_GCD

    http://acm.hdu.edu.cn/showproblem.php?pid=1222 直接用GCD就可以了,gcd大于1表明每次一周后偏移量为0. #include<iostream&g ...

  4. Codeforces_478_C

    http://codeforces.com/problemset/problem/478/C 水. #include<stdio.h> int main() { long long a,b ...

  5. 2019ccpc哈尔滨打铜记

    小学生日记: 2019.10.13,哈尔滨,打了个铜 开头 先说结论,这次失败,我的锅70%,sdl的锅5%,ykh25% Day0 周五, 我们队出现了奇怪的厄运上身 首先是我中途在飞机上数据线突然 ...

  6. 题解【Luogu P6102 谔运算】

    \[ \texttt{Description} \] 给出一个长度为 \(n\) 的数列 \(a\),求 \(\sum\limits_{i=1}\limits^{n}\sum\limits_{j=1} ...

  7. C语言实现matlab的interp2()函数

    项目要用到matlab中的Vq = interp2(X,Y,V,Xq,Yq)函数,即把一个已知经纬度和对应值的矩阵,插值变换到一个给定经纬度网格中,也就是对给定网格填值,需要用到插值,这里使用双线性内 ...

  8. vue路由核心要点(vue-router)

    目录 目录 1.vue-router 是什么? 2.如何使用v-router? 3.vue-router跳转和传参 4.vue-router实现的原理 两种模式 5.vue-router 有哪几种导航 ...

  9. javascript HierarchicalTaskAnalysis-hta编程(.hta)

    main.hta  code: <script>window.resizeTo(400,300);</script> <head> <hta:applicat ...

  10. 01_TypeScript介绍安装

    1.介绍 TypeScript 是由微软开发得一款开源得编程语言:是JavaScript得超级,遵循ES6,ES5规范:更适合开发大型企业项目. 2.安装 npm install -g typesri ...