Skip to content

Instantly share code, notes, and snippets.

@git2samus
Created October 1, 2011 20:40
Show Gist options
  • Save git2samus/1256635 to your computer and use it in GitHub Desktop.
Save git2samus/1256635 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
def HS11DIVS(a, b, x, l, r):
if a % x:
a += x - a % x
current, matches = a, 0
while current <= b:
current_sum = sum(int(str_digit) for str_digit in str(current))
if l <= current_sum <= r:
matches += 1
current += x
return matches % 1000000007
if __name__ == '__main__':
a, b = (int(i) for i in raw_input().split())
x, l, r = (int(i) for i in raw_input().split())
print HS11DIVS(a, b, x, l, r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment