Submission #2731138


Source Code Expand

Copy
n = gets.chomp.to_i
count = 0
num = 1
digit = 0
while count < n do
  nums = num.to_s.split('')
  digit_num = nums.reverse[digit].to_i
  unless digit_num == 0
    puts num
    num += 10 ** digit
    count += 1
    next
  end
  sum = nums.map(&:to_i).inject(:+)
  if (sum * (10 ** digit) - num < 0)
    num += 9 * (10 ** digit)
    digit += 1
    next
  end
  puts num
  num += 10 ** digit
  count += 1
  next
end

Submission Info

Submission Time
Task D - Snuke Numbers
User liwii
Language Ruby (2.3.3)
Score 500
Code Size 436 Byte
Status
Exec Time 17 ms
Memory 1916 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample.txt
All 500 / 500 sample.txt, 1.txt, sample.txt
Case Name Status Exec Time Memory
1.txt 17 ms 1916 KB
sample.txt 6 ms 1788 KB