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 ...
随机推荐
- Slam笔记I
视觉Slam笔记I 第二讲-三位空间刚体运动 点与坐标系: 基础概念: 坐标系:左手系和右手系.右手系更常用.定义坐标系时,会定义世界坐标系,相机坐标系,以及其他关心对象的坐标系.空间中任意一点可由空 ...
- HTTP 错误 500.21 模块 IIS Web Core
如果出现如下图错误 就是iis没有安装Web Core模块 下载并安装DotNetCore.1.0.4_1.1.1-WindowsHosting.exe 安装完成之后会出现如下 证明安装成功.网站也可 ...
- linux golden-dict个性化添加词典
国内有道,百度等参考https://www.jianshu.com/p/9bf577335945如果和我一样,想要添加大名鼎鼎的韦氏词典英文词典,则地址如下https://www.merriam-we ...
- MySQL优化之慢查询日志
慢查询日志概述 所谓慢查询日志,就是用于记录MySQL中响应时间超过设定阈值的SQL语句,通过打开慢查询开关,MySQL会将大于阈值的SQL记录在日志中,以便于分析性能. 慢查询日志选项默认是关闭的, ...
- spring boot项目打war包
1.如果有本地依赖,添加本地依赖到maven <!--lib目录下的jar包--> <dependency> <groupId>com.dm</groupId ...
- 10.map
map Go语言中提供的映射关系容器为map,其内部使用散列表(hash)实现 . map是一种无序的基于key-value的数据结构,Go语言中的map是引用类型,必须初始化才能使用. map定义 ...
- 新手必备 | 史上最全的PyTorch学习资源汇总
目录: PyTorch学习教程.手册 PyTorch视频教程 PyTorch项目资源 - NLP&PyTorch实战 - CV&PyTorch实战 PyTorch论 ...
- php 设置允许跨域请求
php 服务端代码 <?php header('Content-Type: text/html;charset=utf-8'); header('Access-Control-Allow-Ori ...
- python—json
一.json数据类型:是字符串 # json通用数据类型,所有语言都可以用 # {k-v}形式存在,里面只能用双引号"" # 定义json字符串,要用'''{}'''格式 #htt ...
- 记录---java中jsp页面引入jquery路径的问题
今天在jsp页面中引入jquery的时候因为路径不对总是报404,网上的方法找到几种试了试但是最后结果还是不生效,遂想起原先的项目中有引入外部jquery的例子,所以立马看了看,发现当时的项目中是用$ ...