最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

CF1842A - Tenzing and Tsondu

2023-06-25 11:27 作者:您是打尖兒還是住店呢  | 我要投稿

Olympus City recently launched the production of personal starships. Now everyone on Mars can buy one and fly to other planets inexpensively.

Each starship has a number —some positive integer x. Let's define the luckiness of a number x as the difference between the largest and smallest digits of that number. For example, 142857 has 8

?as its largest digit and 1 as its smallest digit, so its luckiness is 8?1=7. And the number 111 has all digits equal to 1, so its luckiness is zero.

Hateehc is a famous Martian blogger who often flies to different corners of the solar system. To release interesting videos even faster, he decided to buy himself a starship. When he came to the store, he saw starships with numbers from l to r inclusively. While in the store, Hateehc wanted to find a starship with the luckiest number.

Since there are a lot of starships in the store, and Hateehc can't program, you have to help the blogger and write a program that answers his question.

-------------------------------------------------------------------中文:

奧林巴斯城最近啟動(dòng)了個(gè)人星艦的生產(chǎn)。 現(xiàn)在火星上的每個(gè)人都可以購(gòu)買(mǎi)一架并以便宜的價(jià)格飛往其他星球。

每艘星艦都有一個(gè)數(shù)字——某個(gè)正整數(shù) x。 讓我們將數(shù)字 x 的幸運(yùn)值定義為該數(shù)字的最大數(shù)字和最小數(shù)字之間的差。 例如,142857 有 8 個(gè)

? 最大的數(shù)字是 1,最小的數(shù)字是 1,所以它的幸運(yùn)是 8?1=7。 而數(shù)字111的所有數(shù)字都等于1,因此它的幸運(yùn)值為零。

Hateehc是一位著名的火星博主,經(jīng)常飛往太陽(yáng)系的不同角落。 為了更快地發(fā)布有趣的視頻,他決定給自己買(mǎi)一艘星際飛船。 來(lái)到店里,他看到了一艘艘編號(hào)從l到r(含)的星艦。 在商店里,Hateehc 想要找到一艘擁有最幸運(yùn)數(shù)字的星艦。

由于商店里有很多星艦,而 Hateehc 不會(huì)編程,所以你必須幫助博主編寫(xiě)一個(gè)程序來(lái)回答他的問(wèn)題。

--------------------------------------------------------題解

判斷是否是lucky 數(shù)字,依次去遍歷即可,但是最大只能是9,所以在r值的選擇就可以去math.min(l+100,r)因?yàn)橹灰钪抵灰^(guò)100的話,最大值就一定是9了;

下面是代碼:


CF1842A - Tenzing and Tsondu的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
大方县| 安阳县| 临猗县| 资兴市| 六枝特区| 白朗县| 洛浦县| 霍州市| 木兰县| 湟中县| 千阳县| 三亚市| 潢川县| 海伦市| 临潭县| 宝兴县| 邹平县| 上林县| 丹巴县| 天镇县| 宁晋县| 上栗县| 香港 | 普陀区| 封开县| 万宁市| 唐海县| 鄂尔多斯市| 林芝县| 罗平县| 钟山县| 兴化市| 陕西省| 广丰县| 武宁县| 上犹县| 德格县| 商都县| 固始县| 福安市| 宕昌县|