Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created March 12, 2018 06:07
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/cc96ba49ba2b09462abf00c40a223b82 to your computer and use it in GitHub Desktop.
Save whatalnk/cc96ba49ba2b09462abf00c40a223b82 to your computer and use it in GitHub Desktop.
AtCoder ABC #090 D. Remainder Reminder
n, k = gets.chomp.split(" ").map(&:to_i)
ans = 0
(1..n).each do |b|
x = n / b
r = n % b
ans += x * [0, b - k].max
ans += [0, r - k + 1].max
end
ans -= n if k == 0
puts ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment