Problem:


Score : 200 points

Problem Statement

Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).

Constraints

1 \leq N \leq 10^4

1 \leq A \leq B \leq 36

All input values are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

Print the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).

Sample Input 1

20 2 5

Sample Output 1

84

Among the integers not greater than 20, the ones whose sums of digits are between 2 and 5, are: 2,3,4,5,11,12,13,14 and 20. We should print the sum of these, 84.

Sample Input 2

10 1 2

Sample Output 2

13

Sample Input 3

100 4 16

Sample Output 3

4554



Sample input:
20 2 5


Sample output:
84

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())

ans = 0
n = str(n)
num = 1
while num <= int(n):
    sum1 = 0
    for s in str(num):
        sum1 += int(s)
        
    if a <= sum1 <= b:
        ans += num
        
    num += 1
    
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
"""
n = 100
a = 4
b = 16
"""
ans = 0
for i in range(n+1):
    s = sum(list(map(int, str(i))))
    if a <= s and s <= b:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
n,a,b = map(int, input().split())
i = 1
sum = 0
while ( i <= n ):
    l = list(str(i))
    s = 0
    for x in l:
        s = s + int(x)
    if a <= s and s <= b:
        sum = sum + i
    i = i + 1
print(sum)

Submission status: Accepted

Solution code:
n,a,b = map(int, input().split())
value = cnt = 0
for i in range(1, n+1):
    lst = []
    lst = list(str(i))
    for num in lst:
        value += int(num)
    if a <= value <= b:
    	cnt += i
    value = 0
print(cnt)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
count=0
for i in range(1,n+1):
    new=str(i)
    lista=sum(list(map(int,new)))
    
    if lista>=a and lista<=b:
        count=count+i
print(count)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
ans=0
for i in range(n+1):
    if a<=sum(list(map(int,list(str(i)))))<=b:
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc083/tasks/abc083_b


import bisect


def digit_sum(a):
    s = str(a)
    total = 0
    for i in range(len(s)):
        total += int(s[i])
    return total


N, A, B = map(int, input().split())

digits = [(digit_sum(i), i) for i in range(1, N + 1)]
sorted_digits = sorted(digits, key=lambda a: a[0])
a_sorted_digits = [sorted_digits[i][0] for i in range(len(sorted_digits))]
left = bisect.bisect_left(a_sorted_digits, A)
right = bisect.bisect_right(a_sorted_digits, B)
print(sum([a[1] for a in sorted_digits[left:right]]))

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
ans=0
for i in range(1, n+1):
  s=list(str(i))
  l=list(map(int,s))
  s=sum(l)
  if a<=s and s<=b:
    ans+=i
print(ans)

Submission status: Accepted

Solution code:
src = input()
values = src.split(' ')
n = int(values[0])
a = int(values[1])
b = int(values[2])

result = 0

for x in range(1, n + 1):
    value = str(x)
    sum = 0
    for c in value:
        sum += int(c)

    if a <= sum and sum <= b:
        result += x

print(result)

Submission status: Accepted

Solution code:
n,a,b=map(int, input().split())
sum=0
for i in range(0,n+1):
  if a<=(i//10000+i//1000%10+i//100%10+i//10%10+i%10)<=b:
    sum+=i
print(sum)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# ABC 083 B - Some Sums
# スペース区切りの整数の入力
b = [int(s) for s in input().split()]
sum = 0
for i in range(1, b[0]+1):
    s = 0
    t = i
    while t != 0:
        s = s + t % 10
        t = t // 10
    if (b[1] <= s) and (s <= b[2]):
        sum = sum + i
print(sum)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
r=0
for i in range(n+1):
    if a<=sum([int(j) for j in str(i)])<=b:
        r+=i
print(r)

Submission status: Accepted

Solution code:
N, A, B = list(map(int, input().split()))
sum = 0
for i in range(1, N + 1):
    ts = 0
    k = len(str(i))
    for j in range(0, k):
        t = (i // 10 ** j) % 10
        ts += t
    if A <= ts <= B:
        sum += i
print(sum)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
c=0
for i in range(1,N+1):
  a=0
  b=i
  while b>0:
    a+=b%10
    b=b//10
  if A<=a<=B:
    c+=i
print(c)

Submission status: Accepted

Solution code:
def abc083b():    
    n, a, b = map(int,input().split())

    cnt = 0
    for num in range(n + 1):    
        if a <=sum([int(i) for i in str(num)]) <= b:
            cnt += num
    print(cnt)

if __name__ == '__main__':
    abc083b()

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())

total=0
for i in range(1,n+1):
  sum_val=sum([int(x) for x in str(i)])
  if a<=sum_val<=b:
    total+=i
print(total)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
ans = 0
for i in range(1, N + 1):
  if A <= sum(map(int, list(str(i)))) <= B:
    ans += i
print(ans)

Submission status: Accepted

Solution code:
def souwa(x):
    total = 0
    while x > 0:
        total += int(x%10)
        x = int(x/10)
    return total

n,a,b = map(int,input().split())
result = 0
for i in range(1,n+1):
    if a <= souwa(i) and souwa(i) <= b:
        result += i
print(result)

Submission status: Accepted

Solution code:
n,a,b=input().split()
n,a,b=int(n),int(a),int(b)
m=len(str(n))
'''
c=0
if n==10**4 and A==1:
    c=1
k=len(str(n))
for i in range(k):
'''
c=0
for i in range(n):
    #map関数はクソ便利
     if a <= sum(list(map(int, str(i+1)))) <= b:
         c+=i+1

print(c)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
counter=0
for m in range(1,n+1):
  s=str(m)
  array=list(map(int,s))
  if a<=sum(array)<=b:
    counter+=m
print(counter)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
 
def find_sum_of_digits(n):
    sum = 0
    int(n)
    while n > 0:
        sum += n % 10
        n //= 10
    return sum
 
total = 0
for i in range(1, n+1):
    sum_of_digits_tmp = find_sum_of_digits(i)
    if a <= sum_of_digits_tmp and sum_of_digits_tmp <= b:
        total += i
 
print(total)

Submission status: Accepted

Solution code:
n,a,b=input().split()
a=int(a)
b=int(b)

ans=0
for i in range(1,int(n)+1):
    if a<=sum(map(int,str(i)))<=b:
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
n,a,b=map(int, input().split())

count=0
for i in range(n+1):
    num_sum=sum([int(x) for x in list(str(i))])
    if num_sum>=a and num_sum<=b:
        count+=i
print(count)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

def ksum(N):
  Nlist = list(map(int, str(N)))
  return sum(Nlist)

numlist = []

for i in range(1, N+1):
  if ksum(i) >= A and ksum(i) <= B:
    numlist.append(i)
    
print(sum(numlist))

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0


def sum_(m):
    res = 0
    while m > 0:
        res += m % 10
        m //= 10
    return res


for i in range(0, n + 1):
    # if a <= sum([int(j) for j in str(i)]) <= b:
    if a <= sum_(i) <= b:
            ans += i
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

ans = 0
for i in range(1, N + 1):
    si = 0
    for s in str(i):
        si += int(s)
    if A <= si <= B:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
  if a<=sum(map(int,str(i)))<=b:
    ans+=i
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
ans = 0
for n in range(1, N + 1):
    if A <= sum(int(c) for c in str(n)) <= B:
        ans += n
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
sum = 0
for i in range(1, n+1):
  isum = 0
  m = i
  while m != 0:
    isum += m%10
    m //= 10
  if a <= isum <= b:
    sum += i
print(sum)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
sum = 0
for i in range(1, n+1):
  isum = 0
  m = i
  for j in range(5):
    isum += m%10
    m //= 10
  if a <= isum <= b:
    sum += i
print(sum)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
t_ans = 0

for i in range(1, n+1):
    i = str(i)
    ans = 0
    for j in range(len(i)):
        ans += int(i[j])
    if a <= ans and ans <= b:
        t_ans += int(i)
print(t_ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

sum_N = 0
for i in range(N+1):
    if A <= sum(list(map(int, list(str(i))))) <= B:
        sum_N += i

print(sum_N)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0
for i in range(n + 1):
    tmp =  sum(map(int, str(i)))
    if a <= tmp and tmp <= b:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
s = 0
for i in range(1, n + 1):
    t = str(i)
    total = sum(list(map(int, list(t))))
    if a <= total <= b:
        s += i
print(s)

Submission status: Accepted

Solution code:
def findSUM(n):
    sum = 0
    while (n > 0):
        sum += n % 10
        n //= 10
    return sum

N ,A ,B = map(int, input().split())

total = 0
for i in range(N+1):
    sum = findSUM(i)
    if (sum >= A and sum <= B):
        total += i

print(total)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

num_sum = 0
for i in range(N+1):
    res = 0
    num = i
    while num > 0:
        q, mod = divmod(num, 10)
        res += mod
        num = q
    if (res >= A) and (res <= B):
        num_sum += i

print(num_sum)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

print (sum([i for i in range(1, N+1) if A <= sum(map(int, str(i))) <= B]))

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
NSUMlist = []
for i in range(1, N + 1):
    NN = list(str(i))
    NNN = [int(_) for _ in NN]
    NSUM = sum(NNN)
    if NSUM >= A and NSUM <= B:
        NSUMlist.append(i)
print(sum(NSUMlist))

Submission status: Accepted

Solution code:
Num,up,down = map(int,input().split())
check2,check3 = 0,0
result= 0

for i in range(1,Num+1):
    check1 = i

    while not check1 == 0:
        check2 = check1 % 10
        check1 = int(check1 / 10)
        check3 += check2

    if up <= check3 <= down:
        result += i
    check3 = 0

print(result)

Submission status: Accepted

Solution code:
from sys import stdin

n, a, b = [int(x) for x in stdin.readline().rstrip().split()]
count = 0

for x in range(1, n+1):
  z = 0
  for y in str(x):
      z += int(y)
      
  if (z >= a) and (z <= b): count += x
    
print(count)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = []
for i in range(1, n+1):
    i_lst = list(map(int, str(i)))
    if a <= sum(i_lst) <= b:
        ans.append(i)
print(sum(ans))

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
d = 0
e = []

for i in range(1,n+1):
  d = sum(map(int,list(str(i))))
  if a <= d <= b:
    e.append(i)
    
print(sum(e))

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
loop = 0
result = 0

while(loop <= n):
    targetNum = list(str(loop))
    sum = 0
    for num in targetNum:
        sum += int(num)

    if a <= sum and sum <= b :
        result += loop

    loop += 1

print(result)

Submission status: Accepted

Solution code:
li = list(map(int,input().split()))
N = li[0]
A = li[1]
B = li[2]
count = 0
for i in range(1,N + 1):
  iti = i % 10
  zyuu = (i - iti) / 10 % 10
  hyaku = ((i - iti) / 10 - zyuu) / 10 % 10
  sen = (((i - iti) / 10 - zyuu) / 10  - hyaku) / 10 % 10
  man = ((((i - iti) / 10 - zyuu) / 10 - hyaku) / 10 - sen) / 10 % 10
  total = iti + zyuu + hyaku + sen + man
  
  if A <= total and B >= total:
    count += i

print(count)

Submission status: Accepted

Solution code:
nab = input()

nab = nab.split()

n = int(nab[0])
a = int(nab[1])
b = int(nab[2])

ans = 0

for i in range(1, n+1):
	s = 0
	q = i
	while q != 0:
		s = s + q % 10
		q = int( q / 10)	
		
	if s >= a and s <= b:
		ans = ans + i
	
print(ans)

Submission status: Accepted

Solution code:
nab = input()

nab = nab.split()

n = int(nab[0])
a = int(nab[1])
b = int(nab[2])

ans = 0

for i in range(1, n+1):
	q =  int(i / 10000)
	r = int( (i - q*10000)/1000 )
	s = int( (i - q*10000 - r*1000)/100 )
	t =  int( (i - q*10000 - r*1000 - s*100)/10 )
	u = int( (i - q*10000 - r*1000 - s*100 - t*10) )
	sum = q + r + s + t + u
	if sum >= a and sum <= b:
		ans = ans + i
		
print(ans)

Submission status: Accepted

Solution code:
def sum_digits(n):
    total = 0
    while n > 0:
        total += n % 10
        n //= 10
    return total


def main():
    n, a, b = map(int, open(0).read().split())
    res = 0
    for i in range(1, n+1):
        total = sum_digits(i)
        if a <= total and total <= b:
            res += i
    print(res)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
print(sum(i for i in range(1, n+1) if a <= sum(map(int, list(str(i)))) <= b))

Submission status: Accepted

Solution code:
def main():
    n, a, b = [int(i) for i in input().split()]
    ans = 0
    for i in range(1,n+1):
        tmp = 0
        for ss in str(i):
            tmp += int(ss)
        if a <= tmp <= b:
            ans += i
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, a, b = [int(i) for i in input().split()]


summ=0
for i in range(1,n+1):
  s = str(i)
  lists = list(s)
  array = list(map(lambda x: int(x), lists))
  
  if sum(array)>=a and sum(array)<=b:
    summ += i
    
print(summ)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0

for i in range(n+1):
    if a <= sum(map(int, list(str(i)))) <= b:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

n, a, b = map(int, input().split())
r = 0
for i in range(n + 1):
    if a <= digitSum(str(i)) <= b:
        r += i
print(r)

Submission status: Accepted

Solution code:
n, a,b = [int(x) for x in input().split()]
print(sum(x for x in range(1,n+1) if a <= sum(map(int,str(x))) <= b ))

Submission status: Accepted

Solution code:
import sys
inputs = input().rstrip().split(' ')

n = int(inputs[0])
a = int(inputs[1])
b = int(inputs[2])

def isNum(Num):
    tmp = Num % 10 + (int(Num/10) % 10) + (int(Num/100) % 10) + (int(Num/1000)  % 10) + (int(Num/10000) % 10)
    if (a<= tmp and tmp <=b):
        return Num
    else:
        return 0
count = 0

for i in range(1,n+1,1):
    count = count + isNum(i)
print(count)

Submission status: Accepted

Solution code:
n,a,b = map(int, input().split())

counter = 0

for i in range(1,n+1):
  tent = i //10000
  thou = (i - tent * 10000) // 1000
  hund = (i - thou * 1000 - tent * 10000) // 100
  ten  = (i - thou * 1000 - hund * 100 - tent * 10000) // 10
  one  =  i - thou * 1000 - hund * 100 - ten * 10 - tent * 10000
  sum_all = tent + thou + hund + ten + one
  if sum_all >= a and sum_all <= b:
    counter += i

print(counter)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
def ten(i):
  wa = 0
  while i != 0:
     wa += i%10
     i = i//10
  return(wa)  

result = 0
for i in range(n + 1):
  if a <= ten(i) and ten(i)<=b:
    result += i
print(result)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
ans = 0
for i in range(1,n+1):
    s = str(i)
    c = sum([int(s[j]) for j in range(len(s))])
    #print(i,c)
    if a <= c <= b:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
    s = sum(map(int, list(str(i))))
    if a <= s and s <= b:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
res = 0
for i in range(N+1):
    if A <= sum(map(int, (list(str(i))))) <= B:
        res += i
print(res)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
    c = sum(map(int, str(i)))
    if a <= c <=b:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int,input().split())
ans = 0
c = int(0)
memo = 0
i = int(0)
for i in range (1, n+1):
    c = 0
    memo = i
    while memo > 0:
        c += int(memo % 10)
        memo = int(memo / 10)
    if c >= a and c <= b:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n + 1):
    s=sum(map(int, str(i)))
    if a <= s <= b:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
def findSumOfDigits(n):
  sum = 0
  while n > 0:
    sum += n % 10
    n = int(n/10)
  return sum

N, A, B = list(map(int, input().split()))
total = 0
for i in range(1, N+1):
  if A <= findSumOfDigits(i) <= B:
    total += i

print(total)

Submission status: Accepted

Solution code:
n, a, b = list(map(int, input().split()))
res = 0
for i in range(1, n+1):
  sum = int(i/10000) + int(i%10000/1000) + int(i%1000/100) + int(i%100/10) + int(i%10)
  if a <= sum and sum <= b:
    res += i

print(res)

Submission status: Accepted

Solution code:
def main():
    N, A, B = list(map(int, input().split()))
    ans = 0
    for i in range(1, N+1):
        i_str = str(i)
        sum_digit =  sum([int(i_str[j]) for j in range(len(i_str))])
        if (A <= sum_digit <= B):
            ans = ans + i
    print(ans)

main()

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())

ans = 0
for i in range(n+1):
  if a <= sum(list(map(int, list(str(i))))) <= b:
    ans += i
print(ans)

Submission status: Accepted

Solution code:
def main():
    N, A, B = map(int, input().split())

    print(sum(n for n in range(1, N+1) if A <= sum(map(int, str(n))) <= B))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N, A, B = map(int, input().split())

    ans = 0
    for n in range(1, N+1):
        if A <= sum(map(int, str(n))) <= B:
            ans += n

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

ans = 0
for n in range(1, N+1):
    if A <= sum(map(int, str(n))) <= B:
        ans += n

print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
res = 0
for i in range(N+1):
    if A <= sum([int(s) for s in str(i)]) <= B:
        res += i
print(res)

#int(s) for s in str(i)

#intとstringの相互互換を活用した。

Submission status: Accepted

Solution code:
N,A,B=[int(x) for x in input().split()]
res=0
for i in range(1,N+1):
  t=sum([int(x) for x in list(str(i))])
  if A<=t<=B:
    res+=i
print(res)

Submission status: Accepted

Solution code:
N,A,B=[int(x) for x in input().split()]
res=0
for i in range(1,N+1):
  t=sum([int(x) for x in list(str(i))])
  if t>=A and t<=B:
    res+=i
print(res)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
N,A,B=map(int,input().split())
c=0
for n in range(1,N+1):
    if A<=sum(map(int,str(n)))<=B:
        c+=n
print(c)

Submission status: Accepted

Solution code:
n, a, b = map(int,input().split())

result_sum = 0
for i in range(1,n+1):
    keta_sum = 0
    for j in range(len(str(i))):
        keta_sum += int(str(i)[j])

    if a <= keta_sum and b >= keta_sum:
        result_sum += i
    keta_sum = 0

print(result_sum)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
ans = 0
for n in range(1, N+1):
    m = sum([int(c) for c in list(str(n))])
    if A <= m <= B:
        ans += n
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
n, a, b = map(int, input().split())
sum_i = 0
for i in range(n + 1):
  base = i
  v5 = np.floor(base / 10000).astype(int)
  base -= v5 * 10000
  v4 = np.floor(base / 1000).astype(int)
  base -= v4 * 1000
  v3 = np.floor(base / 100).astype(int)
  base -= v3 * 100
  v2 = np.floor(base / 10).astype(int)
  base -= v2 * 10
  sum_10_1 = v5 + v4 + v3 + v2 + base
  if a <= sum_10_1 <= b:
    sum_i += i
print(sum_i)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
l=[]
for i in range(1,n+1): #1からNまでの整数を全探索
    ic = list(str(int(i))) #整数を各桁リスト化
    s = list(map(int,ic))
    if sum(s) >= a and sum(s) <= b:
        l.append(i)
print(sum(l))

Submission status: Accepted

Solution code:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
N, A, B = map(int, input().split())
count = 0
for i in range(N):
    s = sum(map(int, (list(str(i+1)))))  # 各桁の和
    if s >= A and s <= B:
        count += i+1
print(str(count))

Submission status: Accepted

Solution code:
n, a, b = list(map(int,input().split()))
ans = 0

for i in range(1, n + 1):
    if a <= sum(map(int, str(i))) <= b:
        ans += i
        
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n, a, b = list(map(int, input().split()))

s = 0

print(sum(i for i in range(1,n+1) if a <= sum(map(int, str(i))) <= b))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n, a, b = list(map(int, input().split()))

s = 0

print(sum(i if a <= sum(map(int, str(i))) <=b else 0
          for i  in range(1,n+1)))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n, a, b = list(map(int, input().split()))

s = 0

for i in range(1, n+1):
    if a <= sum(map(int, str(i))) <=b:
        s += i

print(s)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
numbers = [x for x in range(1, N + 1)]
ans = 0
for number in numbers:
  digit_sum= sum([int(x) for x in list(str(number))])
  if digit_sum<= B and digit_sum>= A:
    ans += number
    
print(ans)

Submission status: Accepted

Solution code:
import math

def findsum(n):
  all_num=0
  while n>0:
    all_num += n%10
    n=math.floor(n/10)
  return all_num
  
n,a,b = map(int, input().split())

sum_num=0
for i in range(n):
  if(a<=findsum(i+1)<=b):
    sum_num+=i+1
print(sum_num)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline

n,a,b = map(int, input().split())

s = 0
for i in range(n+1):
    x = i//(10**4)%10 + i//(10**3)%10 + i//(10**2)%10 + i//10%10 + i%10
    if a <= x and x <= b:
        s += i
print(s)

Submission status: Accepted

Solution code:
n, a, b = list(map(int, input().split()))

count = 0
for i in range(1, n+1):
    check = 0
    for x in list(str(i)):
        check += int(x)

    if a <= check <= b:
        count += i

print(count)

Submission status: Accepted

Solution code:
N,A,B = map(int, input().split())
s = 0
for i in range(1, N+1):
    list_1 = [int(x) for x in list(str(i))]
    k = sum(list_1)
    if k >= A and k <= B:
        s += i
print(s)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
count = 0
for i in range(1,n+1):
  w = sum(list(map(int,str(i))))
  if a<= w <= b:
    count+=i
print(count)

Submission status: Accepted

Solution code:
n, a, b = tuple(map(int, input().split()))

nlist = list(range(1, n+1))
total = 0
for i in nlist:
	val = sum([int(num) for num in str(i)])
	if (val >= a) and (val <= b):
		total += i

print(total)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
def getSumOfDigits(n):
    sum = 0
    while n > 0:
        sum += n%10
        n //= 10  # completely divied
    return sum

total = 0
for n in range(1, N+1):
    sum = getSumOfDigits(n)
    if sum >= A and sum <= B:
        total += n 
        
print(total)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())

x = [str(i) for i in range(1,n+1)]

ans = 0
for str_num in x:
    num = 0
    for j in range(len(str_num)):
        num += int(str_num[j])
    if (a <= num and num <= b):
        ans += int(str_num)

print(ans)

Submission status: Accepted

Solution code:
N,A,B = list(map(int,input().split()))

sum_digid = 0
sum = 0
n = 0

for i in range(1,N+1):
    n=i
    sum_digid=0
    while n>0:
        sum_digid += n%10
        n //= 10

    if sum_digid >= A and sum_digid <= B:
        sum += i

print(sum)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

S = 0
for num in range(N+1):
    s = sum(list(map(int, list(str(num)))))
    if s >= A and s <= B:
        S += num

print(S)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

S = 0
for num in range(N+1):
    s = 0
    a = num
    while num != 0:
        s += num % 10
        num = num // 10
    if s >= A and s <= B:
        S += a

print(S)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
num = 0

for i in range(0, n+1):
    s = str(i)
    sum = 0
    for c in s:
        sum += int(c)

    if (sum >= a) and (sum <= b):
        num += i

print(num)

Submission status: Accepted

Solution code:
n,a,b = map(int, input().split())
print(sum(i for i in range(n+1) if a<=sum(map(int,str(i)))<=b))

Submission status: Accepted

Solution code:
n, a, b = list(map(int, input().split(' ')))
count = 0
for i in range(1, n+1):
    s = [int(x) for x in list(str(i))]
    if a<=sum(s) and sum(s) <= b:
        count += i
print(count)

Submission status: Accepted

Solution code:
n,a,b = map(int, input().split())


num = 0
sum = 0
tmp = 0

#print(n,a,b)

for i in range(1,n+1,1):
  #print(i)
  tmp = 0
  num = i
  while True:
    tmp += num % 10
    num = num // 10
    if num == 0:
      #print( tmp, i )
      if a <= tmp <= b:
        #print( sum )
        sum += i

        
      break

print( sum )

Submission status: Accepted

Solution code:
n, lo, hi = map(int, input().rstrip("\n").split())
print(sum([i if lo <= sum(map(int, str(i))) <= hi else 0 for i in range(n + 1)]))

Submission status: Accepted

Solution code:
n, a, b = [int(number) for number in input().split()]


def sum_of_figure(number):
  n_str = str(number)
  return sum([int(c) for c in n_str])


def in_range(number, minimum, maximum):
  sum_figure = sum_of_figure(number)
  if minimum <= sum_figure and sum_figure <= maximum:
    return True
  else:
    return False

result = 0

for target in range(n + 1):
  if in_range(target, a, b):
    result += target

print(result)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
ans = 0
for k in range(1,n+1):
  K = str(k)
  l = len(K)
  sun = 0
  for i in range(l):
    sun += int(K[i])
  if a <= sun <= b:
    ans += k
print(ans)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())

ans = 0
for i in range(1,n+1):
    s = str(i)
    count = 0
    for j in range(len(s)):
        count += int(s[j])
    if count>=a and count<=b:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
total_sum = 0
for i in range(1, n + 1):
    total = 0
    for j in range(len(str(i))):
        total += int(str(i)[j])
    if a <= total <= b:
        total_sum += i
print(total_sum)

Submission status: Accepted

Solution code:
N,a,b = map(int, input().split())
answer = 0
for i in range(1, N+1):
    if a<=sum(list(map(int,list(str(i)))))<=b:
        answer += i
print(answer)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())

answer = 0
total = 0

for i in range(1,N+1):
    m = str(i)
    array = list(map(int,m))
    total = sum(array)
    if A <= total <= B:
        answer += i
print(answer)

Submission status: Accepted

Solution code:
N,A,B = map(int, input().split())
answer = 0
total = 0
for i in range(1,N+1):
    m = str(i)
    array = list(map(int,m))
    total = sum(array)
    if A <= total <= B:
        answer += i
print(answer)

Submission status: Accepted

Solution code:
c = 0
n,a,b = map(int,input().rstrip().split())

for i in range(1,n+1):
  sum_keta = sum(list(map(int,str(i))))
  if a <= sum_keta <= b:
    c = c + i
    
print(c)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
C = [i for i in range(A,N+1)]
D = [i for i in range(A,10) if i <= B]
for c in C:
    if c >= 10:
        str_c = str(c)
        len_c = len(str_c)
        sum_c = 0
        for i in range(len_c):
            sum_c += int(str_c[i])
        if A <= sum_c <= B:
            D.append(c)
print(sum(D))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N, A, B = map(int,input().split())
    count = 0
    for n in range(1, N+1):
        n = str(n)
        n_sum = 0
        for a in n:
            n_sum += int(a)
        if n_sum >= A and n_sum <= B:
            count += int(n)
    print(count)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())

print(sum(i for i in range(n+1) if a<=sum(map(int,str(i)))<=b))

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())

ans=0
for i in range(1,n+1):
    if a<=sum(map(int,list(str(i))))<=b:
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
res = 0

for n in range(1+N):
  if A <= sum([int(s) for s in str(n)]) <= B:
    res += n
    
print(res)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc083/tasks/abc083_b
# B - Some Sums

n, a, b = list(map(int, input().split()))

target_list = []

# まずは全探索
for i in range(1, n+1):
    tmp_sum = sum([int(x) for x in list(str(i))])
    if a <= tmp_sum <= b:
        target_list.append(i)

print(sum(target_list))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n, a, b = map(int, input().split())
cnt = 0
for i in range(1, n+1):
    sum_a = sum(list(map(int, str(i))))
    if a <= sum_a <= b:
        cnt += i
print(cnt)

Submission status: Accepted

Solution code:
input_data = input()
input_data_list = list(map(int, input_data.split()))
N = input_data_list[0]
A = input_data_list[1]
B = input_data_list[2]
total_sum_digits = 0

for num in range(1, N+1):
    digits_list = [int(digit) for digit in str(num)]
    sum_digits = sum(digits_list)
    if A <= sum_digits <= B:
        total_sum_digits += num

print(total_sum_digits)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0

for i in range(1, n+1):
    if sum(list(map(int, str(i)))) >= a and sum(list(map(int, str(i)))) <= b:
        ans += i
        
print(ans)

Submission status: Accepted

Solution code:
def hantei(a):
    a = str(a)
    a_keta_sum = 0
    for i in range(len(a)):
        a_keta_sum += int(a[i])
    return a_keta_sum


N, A, B = list(map(int,input().split()))
ans = 0

for i in range (N+1):
    if A <= hantei(i) and hantei(i) <= B:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
n,a,b = (int(i) for i in input().split())
res_sum = 0

for nn in range(1, n + 1):
  keta_sum = 0
  
  for i in (str(nn)):
    keta_sum += int(i)
  
  if keta_sum >= a and keta_sum <= b:
    res_sum += nn
    
print(res_sum)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
n_list = [0]
digit_N = len(str(N))

def setDigit(N_max, sum_min, sum_max, digit):
    n_max = int(N_max / (10 ** (digit - 1)))
    for i in range(min(n_max, sum_max, 9) + 1):
        if digit == 1 and i >= sum_min:
            n_list.append(N - N_max + i)
        elif digit == 1 and i < sum_min: continue
        else:
            setDigit(N_max - (i * 10 ** (digit - 1)), max(sum_min - i, 0), sum_max - i, digit - 1)


setDigit(N, A, B, digit_N)

print(sum(n_list))