Submission #37463163


Source Code Expand

require 'prime'

k = gets.chomp.to_i

sqrt = Math.sqrt(k).floor

divisors = []
1.upto(sqrt) do |i|
  div, mod = k.divmod(i)
  next if mod > 0
  divisors << i << div
end

divisors.sort!.uniq!

answer = 0
divisors.each_with_index do |a, index|
  divisors[index..].each do |b|
    ab = a * b
    break if ab > k

    c, mod = k.divmod(ab)

    next if mod > 0

    break if b > c

    answer += 1
  end
end

puts answer

Submission Info

Submission Time
Task 085 - Multiplication 085(★4)
User thatblue
Language Ruby (2.7.1)
Score 4
Code Size 449 Byte
Status AC
Exec Time 256 ms
Memory 14404 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 4 / 4
Status
AC × 3
AC × 36
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, large_01.txt, large_02.txt, large_03.txt, large_04.txt, large_05.txt, large_06.txt, prime_01.txt, prime_02.txt, prime_03.txt, prime_04.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, sample_01.txt, sample_02.txt, sample_03.txt, small_01.txt, small_02.txt, small_03.txt, small_04.txt
Case Name Status Exec Time Memory
hand_01.txt AC 61 ms 14096 KiB
hand_02.txt AC 149 ms 14004 KiB
hand_03.txt AC 68 ms 14304 KiB
hand_04.txt AC 256 ms 14404 KiB
large_01.txt AC 64 ms 14320 KiB
large_02.txt AC 77 ms 14232 KiB
large_03.txt AC 107 ms 14228 KiB
large_04.txt AC 64 ms 14268 KiB
large_05.txt AC 61 ms 14136 KiB
large_06.txt AC 127 ms 14248 KiB
prime_01.txt AC 142 ms 14224 KiB
prime_02.txt AC 141 ms 14204 KiB
prime_03.txt AC 107 ms 14172 KiB
prime_04.txt AC 78 ms 14156 KiB
random_01.txt AC 105 ms 14180 KiB
random_02.txt AC 136 ms 14200 KiB
random_03.txt AC 77 ms 14284 KiB
random_04.txt AC 129 ms 14216 KiB
random_05.txt AC 132 ms 14076 KiB
random_06.txt AC 115 ms 14220 KiB
random_07.txt AC 105 ms 14164 KiB
random_08.txt AC 146 ms 14160 KiB
random_09.txt AC 91 ms 14120 KiB
random_10.txt AC 107 ms 14264 KiB
random_11.txt AC 134 ms 14224 KiB
random_12.txt AC 113 ms 14232 KiB
random_13.txt AC 131 ms 14160 KiB
random_14.txt AC 127 ms 14192 KiB
random_15.txt AC 139 ms 14308 KiB
sample_01.txt AC 56 ms 14132 KiB
sample_02.txt AC 56 ms 14264 KiB
sample_03.txt AC 57 ms 14204 KiB
small_01.txt AC 61 ms 14168 KiB
small_02.txt AC 57 ms 14180 KiB
small_03.txt AC 57 ms 14192 KiB
small_04.txt AC 57 ms 14216 KiB