码迷,mamicode.com
首页 > 其他好文 > 详细

[Daily Coding Problem 70] Nth perfect number

时间:2019-02-06 09:26:03      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:sum   pos   bsp   fast   amp   should   sim   trying   red   

This problem was asked by Microsoft.

A number is considered perfect if its digits sum up to exactly 10.

Given a positive integer n, return the n-th perfect number.

For example, given 1, you should return 19. Given 2, you should return 28.

 

This is one of the problem where you can scratch your head for hours, trying to come up with a "smart" solution but just can‘t. Unfortunately, it doesn‘t seem like there‘s a faster way than simply iterating over all the numbers and keeping track of the current perfect number until we hit n

 

[Daily Coding Problem 70] Nth perfect number

标签:sum   pos   bsp   fast   amp   should   sim   trying   red   

原文地址:https://www.cnblogs.com/lz87/p/10352481.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!