题意:

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. hdu1728 逃离迷宫bfs

    题目链接:http://icpc.njust.edu.cn/Problem/Hdu/1728/ 关于广度优先搜索的第一篇题解.广度优先搜索,就是状态树的层次遍历,一层一层的搜索,直到搜索到目标状态为止 ...

  2. CTF_WriteUp_HTTP基本认证(Basic access authentication)

    HTTP基本认证 在HTTP中,基本认证(英语:Basic access authentication)是允许http用户代理(如:网页浏览器)在请求时,提供用户名和密码 的一种方式.HTTP基本认证 ...

  3. 一个完整的机器学习项目在Python中演练(四)

    大家往往会选择一本数据科学相关书籍或者完成一门在线课程来学习和掌握机器学习.但是,实际情况往往d是,学完之后反而并不清楚这些技术怎样才能被用在实际的项目流程中.就像你的脑海中已经有了一块块" ...

  4. 从零开始发布一个ArcGIS Server地图服务

    @ 目录 一.软件环境搭建 1.数据库安装 1.1.Oracle(可选) 1.1.1.安装Oracle服务端 1.1.2.安装Oracle客户端 1.2.PostgreSQL(可选) 1.2.1.安装 ...

  5. C# 便捷实现可迭代对象间的赋值

    目录 都是迭代,为啥我一定要用foreach 如果换成是字典呢? 关于 foreach 都是迭代,为啥我一定要用foreach ​ 问题起源于本人的一个练手的扑克牌程序:洗完牌之后要发给场上的三人. ...

  6. Python——office编程

    一.office编程需求 二.Excel编程 import xlrd path=input("输入路径:") workbook=xlrd.open_workbook(path)#打 ...

  7. linux中的文件类型、时间戳、文件管理

    一.linux 文件类型 1.普通文件:- ,f 2.目录文件:d 3.链接文件(符号链接):l 4.设备文件 字符设备(线性设备):c 块设备(非线性设备):b 5.命名设备:p 6.套接字文件:s ...

  8. B - Bound Found POJ - 2566(尺取 + 对区间和的绝对值

    B - Bound Found POJ - 2566 Signals of most probably extra-terrestrial origin have been received and ...

  9. Java并发基础08. 造成HashMap非线程安全的原因

    在前面我的一篇总结(6. 线程范围内共享数据)文章中提到,为了数据能在线程范围内使用,我用了 HashMap 来存储不同线程中的数据,key 为当前线程,value 为当前线程中的数据.我取的时候根据 ...

  10. Java 程序该怎么优化?(实战篇)

    面试官:出现了性能问题,该怎么去排查呢? 程序猿:接口响应那么慢,时间都花到哪里去了? 运维喵:为什么你的应用跑着跑着,CPU 就接近 100%? 分享一些真实生产问题排查故事,看看能否涨姿势,能否 ...