[分享] Google codejam 2017 程式设计比赛题目 2 of 4

这题我只答对 Small dataset, Large dataset 我答错了

ProblemTatiana likes to keep things tidy. Her toys are sorted from smallest to largest, her pencils are sorted from shortest to longest and her computers from oldest to newest. One day, when practicing her counting skills, she noticed that some integers, when written in base 10 with no leading zeroes, have their digits sorted in non-decreasing order. Some examples of this are 8, 123, 555, and 224488. She decided to call these numbers tidy. Numbers that do not have this property, like 20, 321, 495 and 999990, are not tidy.She just finished counting all positive integers in ascending order from 1 to N. What was the last tidy number she counted?InputThe first line of the input gives the number of test cases, T. T lines follow. Each line describes a test case with a single integer N, the last number counted by Tatiana.OutputFor each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the last tidy number counted by Tatiana.Limits1 ≤ T ≤ 100.Small dataset1 ≤ N ≤ 1000.Large dataset1 ≤ N ≤ 1018.SampleInput                Output4                    Case #1: 129132                  Case #2: 9991000                 Case #3: 77                    Case #4: 99999999999999999111111111111111110Note that the last sample case would not appear in the Small dataset.

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章