CUC-SUMMER-10-A

A - Transformation: from A to B
CodeForces - 727A

Vasily has a number a, which he wants to turn into a number b. For this purpose, he can do two types of operations:

multiply the current number by 2 (that is, replace the number x by 2·x);
append the digit 1 to the right of current number (that is, replace the number x by 10·x?+?1).
You need to help Vasily to transform the number a into the number b using only the operations described above, or find that it is impossible.

Note that in this task you are not required to minimize the number of operations. It suffices to find any way to transform a into b.

Input
The first line contains two positive integers a and b (1?≤?a?<?b?≤?109) — the number which Vasily has and the number he wants to have.

Output
If there is no way to get b from a, print "NO" (without quotes).

Otherwise print three lines. On the first line print "YES" (without quotes). The second line should contain single integer k — the length of the transformation sequence. On the third line print the sequence of transformations x1,?x2,?...,?xk, where:

x1 should be equal to a,
xk should be equal to b,
xi should be obtained from xi?-?1 using any of two described operations (1?<?i?≤?k).
If there are multiple answers, print any of them.

Example
Input
2 162
Output
YES
5
2 4 8 81 162
Input
4 42
Output
NO
Input
100 40021
Output
YES
5
100 200 2001 4002 40021


題意:你有一個(gè)起始數(shù),你可以乘2或者乘10再加1這兩種操作方式耍目,問怎么操作能夠變成目標(biāo)數(shù)

解法:倒著推即可

代碼:

#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
    double a,b,n,x,y,v,t,ans=999999999;
    scanf("%lf%lf%lf",&a,&b,&n);
    for(int i=0;i<n;i++){
        cin>>x>>y>>v;
        t=sqrt((x-a)*(x-a)+(y-b)*(y-b))/v;
        ans=min(ans,t);
    }
    printf("%.20lf",ans);
    return 0;
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市邻薯,隨后出現(xiàn)的幾起案子丰榴,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 221,548評(píng)論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件滔以,死亡現(xiàn)場離奇詭異,居然都是意外死亡氓拼,警方通過查閱死者的電腦和手機(jī)你画,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,497評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來桃漾,“玉大人坏匪,你說我怎么就攤上這事∏送常” “怎么了适滓?”我有些...
    開封第一講書人閱讀 167,990評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長恋追。 經(jīng)常有香客問我粒竖,道長,這世上最難降的妖魔是什么几于? 我笑而不...
    開封第一講書人閱讀 59,618評(píng)論 1 296
  • 正文 為了忘掉前任蕊苗,我火速辦了婚禮,結(jié)果婚禮上沿彭,老公的妹妹穿的比我還像新娘朽砰。我一直安慰自己,他們只是感情好喉刘,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,618評(píng)論 6 397
  • 文/花漫 我一把揭開白布瞧柔。 她就那樣靜靜地躺著,像睡著了一般睦裳。 火紅的嫁衣襯著肌膚如雪造锅。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,246評(píng)論 1 308
  • 那天廉邑,我揣著相機(jī)與錄音哥蔚,去河邊找鬼倒谷。 笑死,一個(gè)胖子當(dāng)著我的面吹牛糙箍,可吹牛的內(nèi)容都是我干的渤愁。 我是一名探鬼主播,決...
    沈念sama閱讀 40,819評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼深夯,長吁一口氣:“原來是場噩夢啊……” “哼抖格!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起咕晋,我...
    開封第一講書人閱讀 39,725評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤雹拄,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后掌呜,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體办桨,經(jīng)...
    沈念sama閱讀 46,268評(píng)論 1 320
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,356評(píng)論 3 340
  • 正文 我和宋清朗相戀三年站辉,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了呢撞。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,488評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡饰剥,死狀恐怖殊霞,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情汰蓉,我是刑警寧澤绷蹲,帶...
    沈念sama閱讀 36,181評(píng)論 5 350
  • 正文 年R本政府宣布,位于F島的核電站顾孽,受9級(jí)特大地震影響祝钢,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜若厚,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,862評(píng)論 3 333
  • 文/蒙蒙 一拦英、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧测秸,春花似錦疤估、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,331評(píng)論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至沈撞,卻和暖如春慷荔,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背缠俺。 一陣腳步聲響...
    開封第一講書人閱讀 33,445評(píng)論 1 272
  • 我被黑心中介騙來泰國打工显晶, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留贷岸,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,897評(píng)論 3 376
  • 正文 我出身青樓吧碾,卻偏偏與公主長得像,于是被迫代替她去往敵國和親墓卦。 傳聞我的和親對(duì)象是個(gè)殘疾皇子倦春,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,500評(píng)論 2 359

推薦閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,569評(píng)論 0 23
  • 花開花落的樣子(五) 第六章:人生常態(tài) 冷戰(zhàn)。蝕煙與我們似乎像劃清界限了一般落剪,不再與我們一同吃飯睁本,回...
    十三月_阿周閱讀 291評(píng)論 0 0
  • 昨晚朋友圈被國足刷屏,有人發(fā)的振奮人心忠怖,有人發(fā)的搞笑有趣呢堰,而有的人發(fā)的則讓我覺得心里有一個(gè)結(jié),不吐不快凡泣。無...
    巨酷閱讀 240評(píng)論 0 2
  • 在我的印象里小時(shí)候除了課本上的書幾乎沒有什么課外讀物枉疼,小時(shí)候的成長環(huán)境畢竟是落后的,初中也在玩鬧中度過了鞋拟,插一句(...
    一朵太陽花shl閱讀 156評(píng)論 0 0
  • 怎樣才能夠站在資本的背后骂维?一直在不斷的探索和追尋…… 資本的定義是金額的足夠大,使用時(shí)限足夠長贺纲,...
    心安是福鈴兒響叮當(dāng)閱讀 183評(píng)論 0 0