Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created September 1, 2018 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/0667cfb5f7edfe3817d28ae201f2bd5f to your computer and use it in GitHub Desktop.
Save whatalnk/0667cfb5f7edfe3817d28ae201f2bd5f to your computer and use it in GitHub Desktop.
AtCoder ABC #108 C
n, k = gets.chomp.split(" ").map(&:to_i)
a = n / k
if k.odd?
puts a**3
else
b = k / 2
if n - k * a >= b
puts a**3 + (a + 1)**3
else
puts (a**3) * 2
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment