D - Three Integers CodeForces - 1311D
题意:
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的更多相关文章
- 【扩展欧几里得】BAPC2014 I Interesting Integers (Codeforces GYM 100526)
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...
- Divisors of Two Integers CodeForces - 1108B (数学+思维)
Recently you have received two positive integer numbers xx and yy. You forgot them, but you remember ...
- 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 ...
- 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 ...
- 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 ...
- codeforces 1269 E K Integers
E. K Integers 题目连接:https://codeforces.com/contest/1269/problem/E 题意 给了一个排列p,你每次操作可以交换两个相邻的元素,现在问你最少操 ...
- codeforces Educational Codeforces Round 5 A. Comparing Two Long Integers
题目链接:http://codeforces.com/problemset/problem/616/A 题目意思:顾名思义,就是比较两个长度不超过 1e6 的字符串的大小 模拟即可.提供两个版本,数组 ...
- 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 ...
- Codeforces 920G - List Of Integers
920G - List Of Integers 思路:容斥+二分 代码: #include<bits/stdc++.h> using namespace std; #define ll l ...
随机推荐
- 被问到到http的时候你就这么回答!
大家好,我是标题党,啊不,我是小雨小雨,致力于分享有趣的.实用的技术文章. 内容分为翻译和原创,如果有问题,欢迎随时评论或私信,希望和大家一起进步. 分享不易,希望能够得到大家的支持和关注. 什么是互 ...
- NLPer入门指南 | 完美第一步
介绍 你对互联网上的大量文本数据着迷吗?你是否正在寻找处理这些文本数据的方法,但不确定从哪里开始?毕竟,机器识别的是数字,而不是我们语言中的字母.在机器学习中,这可能是一个棘手的问题. 那么,我们如何 ...
- java——基本数据类型
一.整型 bite 1字节 2^0 short 2字节 2^1 int 4字节 2^2 long 8字节 2^3 整形常量默认为int型,所以定义long 型时候要在常量后面加 L 或 l ,其他类 ...
- Jmeter接口测试之案例实战(十一)
在前面的知识体系中详细的介绍了Jmeter测试工具在接口自动化测试中的基础知识,那么今天更新的文章主要是对昨晚的上课内容做个总结. 首先来看Jmeter测试工具在图片上传中的案例应用.首先结合互联网产 ...
- zookeeper java代码实现master 选举
1,master选举使用场景及结构 现在很多时候我们的服务需要7*24小时工作,假如一台机器挂了,我们希望能有其它机器顶替它继续工作.此类问题现在多采用master-salve模式,也就是常说的主从模 ...
- [bzoj4472][树形DP] Salesman
题目 原地址 解说 刚看完这道题感觉还是挺乱的,可能那时候脑子不太清醒,一度觉得自己又要重拾Tarjan了.当然最后还是发觉应该用树形DP. (以下dp[u]代表以u为根的包括自己在内的子树的最大利润 ...
- # CodeCraft-20 (Div. 2)
CodeCraft-20 (Div. 2) A. Grade Allocation 思路 : 无脑水题 代码 #include<iostream> #include<algorith ...
- DAO,Service,Controler的简介
DAO层: DAO层叫数据访问层,全称为data access object,属于一种比较底层,比较基础的操作,具体到对于某个表的增删改查,也就是说某个DAO一定是和数据库的某一张表一一对应的,其中封 ...
- STM32F103ZET6独立看门狗
1.IWDG简介 STM32F103ZET6的独立看门狗(IWDG)是由内部LSI(内部约40KHZ低速时钟)时钟驱动的.由于IWDG是由内部低速时钟驱动,所以就算主时钟发生故障,IWDG依然能够工作 ...
- dis反汇编查看实现
dis库是python(默认的CPython)自带的一个库,可以用来分析字节码 >>> import dis >>> def add(a, b = 0): ... ...