日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Three Integers CodeForces - 1311D(思维+暴力)

發(fā)布時間:2023/12/15 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Three Integers CodeForces - 1311D(思维+暴力) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

You are given three integers a≤b≤c.

In one move, you can add +1 or ?1 to any of these integers (i.e. increase or decrease any number by one). You can perform such operation any (possibly, zero) number of times, you can even perform this operation several times with one number. Note that you cannot make non-positive numbers using such operations.

You have to perform the minimum number of such operations in order to obtain three integers A≤B≤C such that B is divisible by A and C is divisible by B.

You have to answer t independent test cases.

Input
The first line of the input contains one integer t (1≤t≤100) — the number of test cases.

The next t lines describe test cases. Each test case is given on a separate line as three space-separated integers a,b and c (1≤a≤b≤c≤104).

Output
For each test case, print the answer. In the first line print res — the minimum number of operations you have to perform to obtain three integers A≤B≤C such that B is divisible by A and C is divisible by B. On the second line print any suitable triple A,B and C.

Example
Input
8
1 2 3
123 321 456
5 10 15
15 18 21
100 100 101
1 22 29
3 19 38
6 30 46
Output
1
1 1 3
102
114 228 456
4
4 8 16
6
18 18 18
1
100 100 100
7
1 22 22
2
1 19 38
8
6 24 48
思路:因為ABC都是10000以內(nèi)的數(shù)字。按照題意操作之后會有b=k1* a,c=k2 * b=k1 * k2* a。b和c都不會太大,2e4內(nèi)絕對是沒問題的,這樣我們就枚舉a和k1,k2,這樣就大大的縮短了時間。不會有100001000010000這樣的時間復(fù)雜度。
代碼如下:

#include<bits/stdc++.h> #define ll long long using namespace std;int a,b,c;int main() {int t;scanf("%d",&t);while(t--){int x,y,z;scanf("%d%d%d",&a,&b,&c);int ans=1e9;for(int i=1;i<=10000;i++){for(int j=1;j*i<=20000;j++){for(int k=1;i*j*k<=20000;k++){int zz=abs(a-i)+abs(j*i-b)+abs(k*i*j-c);if(ans>zz) ans=zz,x=i,y=i*j,z=i*j*k;}}}cout<<ans<<endl;cout<<x<<" "<<y<<" "<<z<<endl;}return 0; }

努力加油a啊,(o)/~

總結(jié)

以上是生活随笔為你收集整理的Three Integers CodeForces - 1311D(思维+暴力)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 欧美精品福利视频 | 激情六月婷婷 | 日本久久影视 | 97影院| 亚洲国产成人精品久久 | 天天综合网天天综合 | 风间由美一区二区三区 | 人妻换人妻a片爽麻豆 | 电影《走路上学》免费 | 国产成人综合在线观看 | 中文字幕一区二区三区在线观看 | 欧美亚洲一区二区三区四区 | 在线日韩亚洲 | 一区二区三区网 | 免费在线日韩 | 久久影音先锋 | 奇米影视在线观看 | 大香伊人中文字幕精品 | 国产色爱| 草草草在线 | 人妻在卧室被老板疯狂进入 | 国产视频黄 | 色综合激情 | 欧美性视频在线 | 9色在线| 亚洲精品国产精品乱码桃花 | 丰满的女邻居 | 五月天国产 | 3d欧美精品动漫xxxx无尽 | 女女高潮h冰块play失禁百合 | 桃色视屏 | 欧美日韩日本国产 | 日韩欧美一二三 | 青青草公开视频 | 美女扒开下面让男人捅 | 欧美日韩激情 | 人人色视频 | 少妇久久久久久被弄到高潮 | 亚洲观看黄色网 | 免费黄色a级片 | 中文字幕精品一区 | 九九av在线 | 欧美挤奶吃奶水xxxxx | 岛国片免费在线观看 | 欧美日韩欧美日韩在线观看视频 | 手机av免费在线观看 | 色啊色 | 视频一区二区欧美 | 国产乱码久久久久久 | 日本理伦片午夜理伦片 | 色播欧美| 亚洲欧美一区二区三区久久 | 久久人体| 51国产视频 | 人妻体内射精一区二区三区 | 黄色的网站在线 | 国内av在线播放 | 一本一道久久a久久综合蜜桃 | 久久久久久久久久久久久国产 | 谁有av网址 | 国产精品99精品无码视亚 | 国产精品变态另类虐交 | 欧美日韩亚洲精品内裤 | 91精品国产综合久久香蕉 | 国产精品二区三区 | 日韩高清影视 | 精品区一区二区 | www.欧美精品 | 国产色综合视频 | 青青青国内视频在线观看软件 | 日韩中文字幕一区 | 浴室里强摁做开腿呻吟男男 | 午夜av片 | 欧美精品动漫 | 精品视频在线观看一区 | 免费三级黄色 | 欧美韩国日本在线 | 久久精品国产99 | 天天曰天天爽 | 国产精品伦 | 91免费在线视频观看 | 欧美天堂在线观看 | 男女无套免费视频网站动漫 | 一区二区免费在线视频 | 在线观看va | av网站在线观看不卡 | 中文字幕在线看片 | 中文日韩字幕 | 久久老熟女一区二区三区 | 免费一级黄色大片 | 国产精品久久久久久久久绿色 | 久久性生活| 亚洲av无码国产综合专区 | 国产夫妻性生活视频 | 黄色三级a| 中文字幕成人动漫 | 亚洲一区二区三区四区五区xx | 日韩1级片| 在线播放无码后入内射少妇 |