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: Wrong Answer

Solution code:
n,a,b = map(int, input().split())
c = 0
for i in range(1,n+1):
  n4 = n//10**4
  n3 = n//10**3 - n4*10
  n2 = n//10**2 - n4*100 - n3*10
  n1 = n//10**1 - n4*1000 - n3*100 -n2*10
  n0 = n - n4*10000 -n3*1000-n2*100-n1*10
  sum = n4+n3+n2+n1+n0
  if sum>=a and sum<=b:
    c+=sum

Submission status: Wrong Answer

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

sum = 0
for n in range(1, N+1):
  n = '000' + str(n)
  a, b, c, d = int(n[-4]), int(n[-3]), int(n[-2]), int(n[-1])
  if A <= a + b + c + d <= B:
    sum += int(n)
print(sum)

Submission status: Wrong Answer

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

sum = 0
for n in range(0, N+1):
  a, b, c, d = n//1000, n//100, n//10, n%10
  if A <= a + b + c + d <= B:
    sum += n
print(sum)

Submission status: Wrong Answer

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

sum = 0
for n in range(1, N+1):
  a, b = n//10, n%10
  if A <= a + b <= B:
    sum += n
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, a, b = map(int, input().split())
i = 0
some = 0
ansArray = []
result = 0
while i <= n:
  num = str(i)
  counter = len(num)
  for x in range(0, counter, 1) :
    some += int(num[x])
    if some >= a and some <= b:
      ansArray.append(i)
      some = 0
      i += 1
      for ans in ansArray:
        result += ans
print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,A,B = map(int, input().split())
ret = 0
for i in range(N):
  c = 0
  while i:
    c,mod = divmod(i,10)
    c += mod
  if A <= c and c <= B:
    ret += i
print(ret)

Submission status: Time Limit Exceeded

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

N,A,B=map(int,input().split())
ans=0
ans_list=[]
sumlist=[]
for i in range(1,N+1):
    sumlist.append(FindSumOfDigits(i))
    if A<=FindSumOfDigits(i)<=B:
        ans+=i
        ans_list.append(i)
print(ans)
#print(ans_list)
#print(sum_list)

Submission status: Time Limit Exceeded

Solution code:
n,a,b = map(int,input().split())
count = 0
for i in range(1,n):
  c = 0
  while True:
    if i == 0:
      break
    else:
      c += i%10
      i//10
  if a <= c <= b:
    count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
n, a, b = (int(i) for i in input().split())
s=0
h=0
for i in range(1,n):
  j=0
  s=0
  while j<4:
    s += i%10
    i = i/10
  if s>=a and s<=b:
    h += s
    

print(h)

Submission status: Time Limit Exceeded

Solution code:
n, a, b = (int(i) for i in input().split())
s=0
h=0
for i in range(1,n):
  j=0
  s=0
  while j<4:
    s += i%10
    i = i%10
  if s>=a and s<=b:
    h += s
    

print(h)

Submission status: Time Limit Exceeded

Solution code:
n, a, b = (int(i) for i in input().split())
s=0
h=0
for i in range(1,n):
  j=0
  s=0
  while j<5:
    s += i%10
    i = i%10
  if s>=a and s<=b:
    h += s
    

print(h)

Submission status: Time Limit Exceeded

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

def divide(num):
  rest = num
  sum = 0
  while rest > 0:
    num /= 10
    rest %= 10
    sum += rest
  return sum

for i in range(n):
  temp = divide(i+1)
  ans = 0
  if temp>= a and temp <= b:
    ans += temp
print(ans)

Submission status: Time Limit Exceeded

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

arr = []
ans = 0

for i in range(N+1):
    y = i
    while y >= 1:
        arr.append(int(i % 10))
        i /= 10
    if sum(arr)>= A and sum(arr) <= B:
        ans += i
        arr = []
    else:
        arr = []
        
print(ans)

Submission status: Time Limit Exceeded

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

arr = []
ans = 0

for i in range(N):
    y = i
    while y >= 1:
        arr.append(int(i % 10))
        i /= 10
    if sum(arr)>= A and sum(arr) <= B:
        ans += sum(arr)
        arr = []
    else:
        arr = []
        
ptint(ans)

Submission status: Time Limit Exceeded

Solution code:
def Fanc(x):
    ans = 0
    while x > 0:
        ans += x % 10
        x // 10
    return ans     
    
N,A,B = map(int,input().split())
sum = 0
for i in range(1,N + 1):
    if A < Fanc(i) and Fanc(i) < B:
        sum += i
print(sum)

Submission status: Time Limit Exceeded

Solution code:
INPUT=input()
IN=INPUT.split(" ")
#N=int(IN[0])
number=int(IN[0])
#N
A=int(IN[1])
B=int(IN[2])

GOUKEI=0
kazu=0

while kazu<=number:
    X=list(map(int,list(str(kazu))))
    #X = list(map(int, n))
    while len(X) != 4:
        X.reverse()
        X.append(0)
        X.reverse()
    #print(X)
    if A<=sum(X)<=B:
        GOUKEI+=kazu
        #print("add",kazu)
    kazu+=1
print(GOUKEI)

Submission status: Accepted

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

for i in range(0,N+1):

    temp = list(map(int,str(i)))
    temp=sum(temp)
    if temp >=A and temp<=B:
        ans_list.append(i)
            
print(sum(ans_list))

Submission status: Accepted

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

for i in range(0,N+1):
    if i < 10:
        if i >= A and i <=B:
            ans_list.append(i)
    else:
        temp = list(map(int,str(i)))
        temp=sum(temp)
        if temp >=A and temp<=B:
            ans_list.append(i)
            
print(sum(ans_list))

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:
n, a, b = map(int, input().split())
ans = 0

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

Submission status: Accepted

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

result = 0
for i in range(1, N+1):
    num = i//(10**4) + i//(10**3)%10 + i//(10**2)%10 + i//10%10 + i%10
    if A <= num <= B:
        result += i
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
sum_1 = 0
for i in range(1,N+1):
    sum_order = 0
    i_str = str(i)
    n = len(i_str)
    for j in range(0,n):
        sum_order += int(i_str[j])
    if A <= sum_order <= B:
        sum_1 += i
print(sum_1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(map(int,input().split()))

oklist=[]

def keta(x):
    ketalist=[]
    for j in range(len(x)):
        ketalist.append(int(x[j]))
    return(sum(ketalist))
        
    

for i in range(s[0]+1):
    check=keta(str(i))
    if(s[1]<=check and check<=s[2]):
        oklist.append(i)     
sum_=sum(oklist)
print(sum_)

Submission status: Accepted

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

sum = 0
for i in range(N+1):
    x = 0
    for j in range(len(str(i))):
        x = x + int(str(i)[j])
    if A <= x <= B:
        sum = sum + i
print(sum)

Submission status: Accepted

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

ans = 0

for i in range(1,N+1):
  
  x = str(i)
  n = len(x)
  sum = 0
  
  for j in range(0,n):
    sum = sum + int(x[j])
  
  if sum >= A and sum <= 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, 1):
  stri = str(i)
  sum = 0
  for j in range(len(str(i))):
    sum += int(stri[j])
  else:
    if sum >= A and sum <= B:
      ans += i
      
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def sum_of_digits(i: int) -> int:
    result = 0
    for _ in range(len(str(i))):
        i, mod = divmod(i, 10)
        result += mod

    return result


def answer(n: int, a: int, b: int) -> int:
    some_sums = 0
    for i in range(1, n + 1):
        if a <= sum_of_digits(i) <= b:
            some_sums += i

    return some_sums


def main():
    n, a, b = map(int, input().split())
    print(answer(n, a, b))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def calc_sum(num):
    ans = 0
    for i in range(len(str(num))):
        target = num % 10
        num //= 10
        ans += target
    return ans

def main():

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,a,b = list(map(int, input().split()))
def sum_digit(x):
    s = 0
    while x:
        s += x % 10
        x //= 10
    return s
print(sum([i for i in range(1,n+1) if a <= sum_digit(i) <= b]))

Submission status: Accepted

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

Submission status: Accepted

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

ans=0

for i in range(1,N+1):
    sum_all=0
    tmp=i
    while(tmp>9):
        sum_all += tmp%10
        tmp//=10
    sum_all += tmp

    if sum_all>=A and sum_all<=B:
        ans+=i
        # print(i)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def FindSumOfDigits(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):
  Sum = FindSumOfDigits(i+1)
  if A <= Sum and Sum <= B:
    total += i+1

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Sum = 0
for i in range(N):
  o = (i+1)//10000
  a = (i+1)%10000//1000
  b = (i+1)%1000//100
  c = (i+1)%100//10
  d = (i+1)%10
  e= o+a+b+c+d
  if e >= A and e <= B:
    Sum = Sum + (i+1)

print(Sum)

Submission status: Accepted

Solution code:
lst = input().split()
N = int(lst[0])
A = int(lst[1])
B = int(lst[2])

def sum(n):
   result = 0
   s = str(n)
   for i in range(len(s)):
      result += int(s[i])
   return result

count = 0

for i in range(1, N+1):
   if A <= sum(i) <= B:
      count += i

print(count)

Submission status: Accepted

Solution code:
def reverse(num):
    sum1 = 0
    while (num > 0):
        remainder = num % 10
        sum1 = remainder+sum1
        num = num // 10
    return sum1

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
l = []
c = 0
k = 0

for i in range(n+1):
    k = i
    c = 0
    while (i > 0):
        c += i%10
        i //= 10
    if (a <= c <= b):
        l.append(k)

print(sum(l))

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
ans=[]
for i in range(1,N+1):
  j=i//10000+(i%10000)//1000+(i%1000)//100+(i%100)//10+(i%10)//1
  if A<=j<=B:
    ans.append(i)
  
print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
for n in range(1,N+1):
    val = n % 10
    tmp = n
    while tmp // 10 > 0:
        
        tmp = tmp // 10
        val += tmp % 10
    if val >= A and val <= B:
        cnt += n
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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, str(i)))) <= b:
        ans = ans + i

print(ans)

Submission status: Accepted

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

L = [i for i in range(1, N+1)]
M = []
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

for i in range(N):
    if digitSum(L[i]) >= A and digitSum(L[i]) <= B:
        M.append(L[i])
        

        
print(sum(M))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

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

ans = 0
for i in range(1, n+1):
    tmp = 0
    for j in str(i):
        tmp += int(j)

    if tmp >= a and tmp <= b:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
ans = []
for i in range(1, N + 1):
    i = str(i)
    tmp = 0
    for j in range(len(i)):
        tmp += int(i[j])
    if A <= tmp <= B:
        ans.append(int(i))

print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

N,a,b = map(int,input().split())
c = 0
total =0
for i in range(N+1):
    c = findSumOfDigits(i)
    if a <= c <= b:
        # print(i)
        # print(c)
        total += i
        # print(total)
print(total)

Submission status: Accepted

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

def caluculate(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n = n // 10
    return sum

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

print(ans)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
con = 0
for i in range(1 , N + 1):
  a1 = i // 10000
  a2 = (i - a1 * 10000)// 1000
  a3 = (i - a1 * 10000 - a2 * 1000)// 100
  a4 = (i - a1 * 10000 - a2 * 1000 - a3 * 100) // 10
  a5 = i % 10
  if A <= a1 + a2+ a3 + a4 + a5 <= B:
    con += i
print(con)

Submission status: Accepted

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

for i in range(1,n+1):
    mod = 0
    div = i
    while div > 0:
        mod += (div % 10)
        div //= 10
    if mod >= a and mod <= b:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, A, B = LI()

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

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
# import math
# import statistics
# import itertools
# a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(int(i))
N,A,B= map(int,input().split())
# f = list(map(int,input().split()))
# g = [input().split for _ in range(a)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen
count=0
ans=[]
for i in range(1,N+1):
    cal=[]
    for k in str(i):
        cal.append(int(k))

    if A<=sum(cal)<=B:
        ans.append(i)
        
print(sum(ans))

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:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

#        tmp = list([int(i) for i in (list(str(i)))])

def main():
    n,a,b = map(int,input().split())
    numbers=[]
    tmp=0

    for i in range(1,n+1):
        if i >=a and i <=b and i < 10:
            numbers.append(i)
        else:
            tmp_array=list(map(int,list(str(i))))
            if len(tmp_array) > 1:
                for j in tmp_array:
                    tmp+=j
                if tmp >=a and tmp <=b:
                    numbers.append(i)
                tmp=0
            else:
                continue
    print(sum(numbers))
            
if __name__=="__main__":
    main()

Submission status: Accepted

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

inp = list(map(int,input().split()))
N = inp[0]
A = inp[1]
B = inp[2]
l=list()

sd = 0
for i in range(N+1):
    x = FindSumOfDigits(i)
    if A <= x <= B:
        sd = sd + i
    
print(sd)

Submission status: Accepted

Solution code:
def myfunc(A, B):
    def resfunc(x):
        if A <= sum(map(int,list(str(x)))) <=B:
            return x
        else:
            return 0
    return resfunc

N, A, B = map(int, input().split())
print(sum(map(myfunc(A,B), range(1, N+1))))

Submission status: Accepted

Solution code:
inp = list(map(int,input().split()))
N = inp[0]
A = inp[1]
B = inp[2]
l=list()
for i in range(N+1):
    n0 = i % 10
    n1 = (i % 100 - n0) // 10
    n2 = (i % 1000 - n0 - n1*10) // 100
    n3 = (i % 10000 - n0 - n1*10 - n2*100) // 1000
    n4 = (i % 100000 - n0 - n1*10 - n2*100 - n3*1000) // 10000
    if A <= n0+n1+n2+n3+n4 <= B:
        l.append(i)
print(sum(l))

Submission status: Accepted

Solution code:

[N,A,B] = list(map(int,input().split()))
out=0

for dam in range(1,N+1):
    L = list(str(dam))
    wa=0
    for i in range(len(L)):
        wa+=int(L[i])
    if wa>=A and wa<=B:
        out+=int(''.join(L))
    # print('L,wa,out:',L,wa,out)

print(out)

Submission status: Accepted

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

ans = 0
for num in range(n+1):
    str_num = str(num)
    num_list = list(str_num)
    total = sum([int(i) for i in num_list])
    if total >= a and total <= b:
        ans+=num
print(ans)

Submission status: Accepted

Solution code:
n_num, a_num, b_num = map(int, input().split())

def digit_sum(num):
    str_num = str(num)
    digit_num = 0
    for s in str_num:
        digit_num += int(s)
    return digit_num

cnt = 0
for n in range(1, n_num+1):
    if a_num <= digit_sum(n) <= b_num:

        cnt += n
        
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

l = list(range(0))

for i in range(n+1):
    res = sum(list(map(int, str(i))))
    if res >= a and res <= b:
        l.append(i)

ans = sum(list(l))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
T=[]
for i in range(1,N+1):
    t=str(i)
    count=0
    for j in range(len(t)):
        count += int(t[j])
    if A <= count <= B:
        T.append(i)
print(sum(T))

Submission status: Accepted

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

def ten_sumfunc(n):
    ans = 0
    while(n>0):
        ans += n%10
        n = n//10
    return ans

total = 0
for i in range(N+1):
    sum1 = ten_sumfunc(i)
    if A <= sum1 and sum1 <= B:
        total += i
        
print(total)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
ans=0
for i in range(N+1):
    j=sum(map(int,list(str(i))))
    if A<=j<=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):
    t = 0
    v = i
    while v > 0:
        t += v%10
        v//=10
    if a <= t <= 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(list(map(int, str(i)))) <= b:
    ans += i
    
print(ans)

Submission status: Accepted

Solution code:
mycode = r'''
# distutils: language=c++
# cython: language_level=3
# cython: boundscheck=False
# cython: wraparound=False
# cython: infer_types=True
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

# define 
ctypedef long long LL

# 読み込みはpython側で行う
import numpy as np
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.readline #文字列読み込む時はこっち

def ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)

cdef LL i,j,k,_



# 桁DPか！？と思ったけど、制約が小さかった
cdef LL N,A,B,a,ans
N,A,B=ints()
# これはpythonで楽に実装できることを利用しよう
ans=0
for a in range(1,N+1):
    s=sum(map(int,str(a))) #pythonはこういう処理が楽なところが神っすよね
    if A<=s<=B:
        ans += a
print(ans)


'''

import sys
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    import os
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
r = 0
for i in range(n + 1):
    c = 0
    j = i
    for k in range(5):
        c += j % 10
        j = j//10
    if a <= c and c <= b:
        r += i

    
print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

ans = 0
for i in range(1, n+1):
    _sum = 0
    tmp_i = i
    while tmp_i:
        _sum += (tmp_i % 10)
        tmp_i //= 10
    if a <= _sum <= 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):
  x = sum(list(map(int, str(i))))
  if A <= x <= 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):
  k = list(str(i))
  sum_i = 0
  for j in k:
    sum_i += int(j)
  if A <= sum_i <= B:
    ans += i
    
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

S = input().split()

N = int(S[0])
A = int(S[1])
B = int(S[2])

total = 0

for i in range(1, N+1):
    j = i
    dig = 0
    while i > 0:
        dig += i % 10
        i = int(i / 10)
    if dig >= A and dig <= B:
        total += j

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    n, a, b = map(int, input().split())

    ans = 0
    for n in range(n + 1):
        keta = len(str(n))
        wa = 0
        for m in range(keta):
            tmp = str(n)
            wa = wa + int(tmp[-m-1])
        if a <= wa <= b:
            ans = ans + n

    print(ans)

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

Solution code:
num_in = [int(i) for i in input().split()]

def calc_dig_sum(num):
    num_str = str(num)
    ret = 0
    for c in num_str:
        ret += int(c)
    return ret

sum = 0
for i in range(1, num_in[0]+1):
    if num_in[1] <= calc_dig_sum(i) <= num_in[2]:
        sum += i

print(sum)

Submission status: Accepted

Solution code:
x = list(map(int,input().split()))
n = int(x[0])
a = int(x[1])
b = int(x[2])

res = 0

for i in range(n+1):
  m = sum([int(r) for r in list(str(i))])
  if a <= m <= 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):
    x = list(str(i))
    x = list(map(int,x))
    x = sum(x)
    if a <= x <= b:
        ans += i
print(ans)

Submission status: Accepted

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

al = []
for i in range(1, N + 1):
    checkno = 0

    for j in range(len(str(i))):
        str_i = str(i)
        checkno += int(str_i[j])
    if A <= checkno and checkno <= B:
        al.append(i)

print(sum(al))

Submission status: Accepted

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

ans = 0
for num in range(1, n+1):
    p = num
    digit_sum = 0
    while p > 0:
        digit_sum += p % 10
        p //= 10
    if a<= digit_sum <= b:
        ans += num
print(ans)

Submission status: Accepted

Solution code:

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

ans = 0

for i in range(N+1):
    x = i%10
    if i >= 10:
        x += (i%100-i%10)/10
        if i >= 100:
            x += (i%1000-i%100)/100
            if i >= 1000:
                x += (i%10000-i%1000)/1000
                if i == 10000:
                    x=1
    if A <= x <= 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):
    x = str(i)
    cnt = 0
    for j in range(len(x)):
        cnt += int(x[j])
    if a <= cnt and cnt <= b:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

res = []

for n in range(1, N+1):
    i = list(str(n))
    i = [int(n) for n in i]
    if A <= sum(i) <= B:
        res.append(int(n))

print(sum(res))

Submission status: Accepted

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

Submission status: Accepted

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

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

def findSumOfDigits(num):
    s = 0
    while num > 0:
        s += int(num % 10)
        num  = int(num / 10)
    return s


for i in range(n + 1):
    s = findSumOfDigits(i)
    if a <= s <= b:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
n, a, b = [int(x) for x in stdin.readline().rstrip().split()]
sum = 0

for x in range(1,n+1):
   l = x // 10000
   m = (x % 10000) // 1000
   n = (x % 1000) // 100
   o = (x % 100) // 10
   p = x % 10
   if l+m+n+o+p >= a and l+m+n+o+p <= b:
      sum += x

print(sum)

Submission status: Accepted

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

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