题意:

a<=b<=c

输出A,B,C要求B是A的倍数,C是B的倍数,并且输出a,b,c变成A,B,C需要的最小次数。

题解:写了半天的二分,后来发现思路错了,,,暴力就能过。。

三层for,第二层是第一层的倍数,第三层是第二层的倍数。。。。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e4;
const ll INF=1e18+;
struct stu
{
ll a,b,c;
}x;
void solve(){
ll a1,b1,c1;
cin>>a1>>b1>>c1;
ll ans=INF;
for(ll a=;a<=N;a++){
for(ll b=a;b<=N+N;b+=a){
for(ll c=b;c<=N+N+N;c+=b){
ll sum=abs(c-c1)+abs(b1-b)+abs(a1-a);
if(sum<ans){
ans=sum;
x.a=a;
x.b=b;
x.c=c;
}
}
}
}
cout<<ans<<endl;
cout<<x.a<<" "<<x.b<<" "<<x.c<<endl;
} int main(){
ll t;
ios::sync_with_stdio();
cin>>t;
while(t--) solve(); return ;
}

D - Three Integers CodeForces - 1311D的更多相关文章

  1. 【扩展欧几里得】BAPC2014 I Interesting Integers (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

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

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

  3. Codeforces Educational Codeforces Round 5 A. Comparing Two Long Integers 高精度比大小,模拟

    A. Comparing Two Long Integers 题目连接: http://www.codeforces.com/contest/616/problem/A Description You ...

  4. codeforces Round #440 A Search for Pretty Integers【hash/排序】

    A. Search for Pretty Integers [题目链接]:http://codeforces.com/contest/872/problem/A time limit per test ...

  5. Educational Codeforces Round 37 G. List Of Integers (二分,容斥定律,数论)

    G. List Of Integers time limit per test 5 seconds memory limit per test 256 megabytes input standard ...

  6. codeforces 1269 E K Integers

    E. K Integers 题目连接:https://codeforces.com/contest/1269/problem/E 题意 给了一个排列p,你每次操作可以交换两个相邻的元素,现在问你最少操 ...

  7. codeforces Educational Codeforces Round 5 A. Comparing Two Long Integers

    题目链接:http://codeforces.com/problemset/problem/616/A 题目意思:顾名思义,就是比较两个长度不超过 1e6 的字符串的大小 模拟即可.提供两个版本,数组 ...

  8. Educational Codeforces Round 5 A. Comparing Two Long Integers

    A. Comparing Two Long Integers time limit per test 2 seconds memory limit per test 256 megabytes inp ...

  9. Codeforces 920G - List Of Integers

    920G - List Of Integers 思路:容斥+二分 代码: #include<bits/stdc++.h> using namespace std; #define ll l ...

随机推荐

  1. cookie sessionStorage localStorage 使用小结

    1.cookie 随http 一起发送 2.webStorage 客户端本地存储功能 可以在客户端 本地建立 一个数据库 不参与与服务器的通讯 setItem (key, value)   —— 保存 ...

  2. Linux时间和现实时间不同步解决方案

    输入三条命令 yum install ntpdate -y ntpdate tiger.sina.com.cnping tiger.sina.com.cn 然后输入date检查时间是否已经同步

  3. [leetcode] 位操作题解

    子集 题目[78]:给定一组不含重复元素的整数数组 nums,返回该数组所有可能的子集(幂集). 示例: 输入: nums = [1,2,3] 输出: [ [3],   [1],   [2],   [ ...

  4. Samba centos7文件共享服务器搭建教程,可以更改任意需求操作配置详解。

    先安装软件   yum -y install samba-client 请看如下配置文件说明 [gongxiang]       comment = This is my shared folder  ...

  5. Python第十二章-多进程和多线程01-多进程

    多进程和多线程 一.进程 1.1 进程的引入 现实生活中,有很多的场景中的事情是同时进行的,比如开车的时候 手和脚共同来驾驶汽车,再比如唱歌跳舞也是同时进行的:试想,如果把唱歌和跳舞这2件事情分开依次 ...

  6. Python批量修改文件名模板

    源码如下:import os import re import sys filePath = r'F:\BaiduNetdiskDownload\COVID-19CTSeg\3DUNet-Pytorc ...

  7. Redis对象——哈希(Hash)

    哈希在很多编程语言中都有着很广泛的应用,而在Redis中也是如此,在redis中,哈希类型是指Redis键值对中的值本身又是一个键值对结构,形如value=[{field1,value1},...{f ...

  8. Java实现tif/tiff/bmp图片转换png图片

    package org.analysisitem20181016.test; import java.io.File; import java.io.FileOutputStream; import ...

  9. D 【BJOI2018】求和

    时间限制 : 20000 MS   空间限制 : 565536 KB 评测说明 : 2s,512m 问题描述 master 对树上的求和非常感兴趣.他生成了一棵有根树,并且希望多次询问这棵树上一段路径 ...

  10. Java并发基础02. 传统线程技术中的定时器技术

    传统线程技术中有个定时器,定时器的类是Timer,我们使用定时器的目的就是给它安排任务,让它在指定的时间完成任务.所以先来看一下Timer类中的方法(主要看常用的TimerTask()方法): 前面两 ...