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=list(map(int,input().split(" ")))
sumn=0 # 求める総和

# 1以上N以下の数について
for i in range(1,N+1):
    sumi=sum(list(map(int,list(str(i))))) # 各桁の総和を求める

    if A<=sumi<=B: # 総和が範囲内なら
        sumn+=i

print(sumn)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = [int(x) for x in input().split()]
N = x[0]
A = x[1]
B = x[2]
def check(x):
  ans = 0
  while x >= 10:
    ans += x%10
    x = x//10  
  ans += x
  return ans
ans1 = 0
for i in range(N):
  i = i+1
  if (check(i) >= A) & (check(i) <= B):
    ans1 += i

print(ans1)

Submission status: Accepted

Solution code:
x = [int(x) for x in input().split()]
N = x[0]
A = x[1]
B = x[2]
ans = 0
for i in range(N):
  i = i+1
  to_int = [int(i) for i in list(str(i))]
  X = sum(to_int)
  if (X >= A) & (X <= B) :
    ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def calc_sum(n):
    dr = 0
    while(True):
        dr += n % 10
        n = n // 10
        if n == 0:
            break
    return dr

count = 0
for i in range(1, n + 1):
    sum = calc_sum(i)
    if (a <= sum) and (b >= sum):
        count += i

print(count)

Submission status: Accepted

Solution code:
def calc_digit_sum(num):
    length = len(str(num))
    digit_sum = 0

    for i in range(1, length + 1):
        digit_sum += num % 10
        num //= 10

    return digit_sum

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

for i in range(1, N + 1):
    digit_sum = calc_digit_sum(i)

    if digit_sum >= A and digit_sum <= B:
        ans += i

print(ans)

Submission status: Accepted

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

clear_list = []
for i in range(1, n+1):

    # 各桁の合計値を出す
    str_n = str(i)
    str_n_array = list(map(int, str_n))

    if a <= sum(str_n_array) <= b:
        clear_list.append(i)
print(sum(clear_list))

Submission status: Accepted

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

Submission status: Accepted

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

result = 0
for i in range(1, n + 1):
    num = str(i)
    sum = 0
    for j in range(len(num)):
        sum += int(num[j])

    if a <= sum <= b:
        result += int(num)
print(result)

Submission status: Accepted

Solution code:
# coding: utf-8

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

total = 0
for i in range(n):
    i_str = str(i+1)
    num = 0
    for j in range(len(i_str)):
        num += int(i_str[j])
    if a <= num <= b:
        total += i+1

print(total)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
total=0
for i in range(1,n+1):
  sum_digits = sum([int(i) for i in str(i)])
  if a <= sum_digits <= 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(int(c) for c in str(i)) <= b:
    ans += i
print(ans)

Submission status: Accepted

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

n,a,b = map(int, input().split())
total = 0
for i in range(n+1):
    s = findSumofDigits(i)
    if a<= s <=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):
    n10000 = int(i/10000)
    n1000 =int(i/1000)-n10000*10
    n100 =int(i/100)-n1000*10-n10000*100
    n10 = int(i/10)-n100*10-n1000*100-n10000*1000
    n1 = int(i)-n10*10-n100*100-n1000*1000-n10000*10000
    s = n10000+n1000+n100+n10+n1
    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()]

total = 0

for i in range(1,n+1):
    point = 0
    s = str(i)
    for j in s:
        point += int(j)
    if a<=point<=b:
        total += i

print(total)

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

all = 0
for i in range(1, n+1):
    sum = 0
    j = i
    while(j > 0):
        sum +=  j % 10
        j = j // 10
    if a <= sum <= b:
        all += i

print(all)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
S=0
for i in range(N+1):
    Q=list(str(i))
    U=0
    for j in range(len(Q)):
        U+=int(Q[j])
    if U>=A and U<=B:
        S+=i
print(S)

Submission status: Accepted

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

tmpSumDigit = 0
totalSumDigit = 0

for number in range(n):
  number += 1
  numberStr = list(str(number))
  for digitNumber in numberStr:
    tmpSumDigit = tmpSumDigit + int(digitNumber)
  if tmpSumDigit >= a and tmpSumDigit <= b:
    totalSumDigit = totalSumDigit + number
  tmpSumDigit = 0

print(totalSumDigit)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
sumdict = dict()
for i in range(1, 37) :
    sumdict[i] = [0]
for i in range(1, n + 1) :
    sumofi = sum([int(k) for k in list(str(i))])
    sumdict[sumofi] += [i]
ans = 0
for i in range(a, b + 1) :
    ans += sum(sumdict[i])
print(ans)

Submission status: Accepted

Solution code:
N = list(map(int,input().split()))
n = 0
for i in range(1,N[0]+1):
  p = sum(list(map(int, str(i))))
  if  (N[1] <= p) and (N[2] >= p):
    n = n + i
print(n)

Submission status: Accepted

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

def sumEachDigit(n):
    s = str(n)
    array = list(map(int, s))
    return sum(array)

res = 0
for i in range(1, N+1):
    sum_i = sumEachDigit(i)
    if sum_i >= A and sum_i <= B:
        res += i

print(res)

Submission status: Accepted

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

S=[]
for i in range(1,N+1):
    tmp=list(map(int,str(i)))
    S.append(sum(tmp))

Ans=0
for i in range(N):
    if S[i] >= A and S[i]<=B:
        Ans+=i+1
print(Ans)

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

Solution code:
def examB():
    N, A, B = LI()
    cur = 0
    for i in range(1,N+1):
        judge = 0; icur = i
        while(icur>0):
            judge +=icur%10
            icur //=10
        if A<=judge<=B:
            cur +=i
    print(cur)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Submission status: Accepted

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

res = 0

for n in range(N + 1):
    sum_digit = 0
    i = n
    while i:
        i, reminder = divmod(i, 10)
        sum_digit += reminder
    if A <= sum_digit <= B:
        res += n
print(res)

Submission status: Accepted

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

a, b, c, d, e = 0, 0, 0, 0, 0
ans = 0

for i in range(N+1):
    n = i

    a = n // 10000
    n = n -10000 * a
    
    b = n // 1000
    n = n -1000 * b

    c = n // 100
    n = n -100 * c

    d = n // 10
    n = n -10 * d

    e = n

    sum = a + b + c + d + e
    if sum >= A and sum <= B:
        ans += i

print(ans)

Submission status: Accepted

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

a, b, c, d, e = 0, 0, 0, 0, 0
ans = 0

for i in range(1, N+1):
    e += 1
    if e == 10:
        d += 1
        e = 0

    if d == 10:
        c += 1
        d = 0

    if c == 10:
        b += 1
        c = 0

    if b == 10:
        a += 1
        b = 0

    sum = a + b + c + d + e
    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 num in range(1, N+1):
    num = str(num)
    tmp_sum = 0
    for num_i in num:
        tmp_sum += int(num_i)
    if (tmp_sum >= A) & (tmp_sum <= B):
        ans += int(num)
print(ans)

Submission status: Accepted

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

total = 0

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
cnt = 0
for i in range(2):
    for j in range(10):
        for k in range(10):
            for l in range(10):
                for m in range(10):
                    num = 10000*i+1000*j+100*k+10*l+m
                    if num>n:
                        break
                    if a<=i+j+k+l+m<=b:
                        cnt+=num
print(cnt)

Submission status: Accepted

Solution code:
import numpy as np

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

nl = np.array([i for i in range(1, n + 1)])
sumlist = np.array([sum(map(int, str(i))) for i in range(1, n + 1)])
# sumlist = np.array(sumlist)

mask = (sumlist >= a) & (sumlist <= b)

ans = sum(nl[mask])

print(ans)

Submission status: Accepted

Solution code:
def check(x, a, b):
    sum = 0
    while x != 0:
        sum += x % 10
        x //= 10
    if a <= sum <= b:
        return True
    return False


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

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
r=[0]*37
for i in range(N+1):
  count=0
  for j in range(len(str(i))):
    count +=int(str(i)[j])
  r[count] +=i
print(sum(r[A:B+1]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC 083: B – Some Sums
n, a, b = [int(s) for s in input().split()]
sum_of_integers = 0

for i in range(1, n + 1):

    is_a_b = True
    sum_of_digits = 0

    for digit in list(str(i)):
        sum_of_digits += int(digit)

    if sum_of_digits < a or sum_of_digits > b:
        is_a_b = False
    
    if is_a_b:
        sum_of_integers += i

print(sum_of_integers)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n,a,b=map(int,input().split())
ans=[]
s=''
l=[]
for i in range(1,n+1):
    s=str(i)
    l=list(s)
    for j in range(len(l)):
        l[j]=int(l[j])
    if a<=sum(l)<=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(A,N+1):
  S = sum(map(int,list(str(i))))
  if A <= S <= 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:
n, a, b = map(int, input().split())

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

Submission status: Accepted

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

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

        s = list(map(int, list(str(i))))
        ss = sum(s)
        if A <= ss <= B:
            cnt += i

    print(cnt)


main()

Submission status: Accepted

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

def digitSum(i):
  s = str(i)
  array = list(map(int, s))
  return sum(array)

for i in range(1,n+1):
  if a<=digitSum(i)<=b:
    ans.append(i)

print(sum(ans))

Submission status: Accepted

Solution code:
def digit_sum(num):
    total_num = 0
    while num > 0:
        total_num += num % 10
        num //= 10
    return total_num
num_list= []
n, a, b = map(int, input().split())
for i in range(1,n+1):
    num = digit_sum(i)
    if num >= a and num <= b:
        num_list.append(i)
print(sum(num_list))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
cnt = 0
N,A,B = map(int,input().split())
for n in range(1,N+1):
    digit_sum = 0
    str_N = str(n)
    for digit in str_N:
        digit_sum += int(digit)
    if A <= digit_sum <= B:
        cnt += n
        #print(n)
print(cnt)

Submission status: Accepted

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

print(oo)

Submission status: Accepted

Solution code:
def sums(n):
    s=sum(map(int,str(n)))
    return s

ans=0
N,a,b=map(int,input().split())
for i in range(1,N+1):
    if a<=sums(i) and sums(i)<=b:
        ans+=i
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(1, N+1):
    j = i
    tmp = 0
    while j != 0:
        tmp += j % 10
        j = j // 10
        
    if A <= tmp and tmp <= 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):
    r = (i - i % 10000)
    s = (i - i % 1000)
    t = (i - i % 100)
    u = (i - i % 10)
    v = i % 10

    u = (u - t) / 10    
    t = (t - s) / 100
    s = (s - r) / 1000
    r = r / 10000
    
    if A <= s+t+u+v+r and r+s+t+u+v <= 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):
    c = sum(int(j) for j in str(i))
    if c >= a and c <= b:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b = inpl()
res = 0
for i in range(1,n+1):
    tmp = str(i)
    cnt = 0
    for j in tmp:
        cnt += int(j)
    if a <= cnt <= b:
        res += i
print(res)

Submission status: Accepted

Solution code:
# ABC083 B - Some Sums
# 2019/11/07

N,A,B = map(int, open(0).read().split())
# print(N, A, B)
ans = 0
for i in range(1, N+1):
    sum_digit = sum([int(i) for i in list(str(i))])
    if A <= sum_digit <= B:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
def sod(n):
    o=n//10000
    p=(n//1000)%10
    q=(n//100)%10
    r=(n//10)%10
    s=n%10
    return o+p+q+r+s

N,A,B=map(int,input().split())
ans=0
for i in range(1,N+1):
    if A<=sod(i)<=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):
    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())
count = 0
for i in range(1,N+1):
  M = len(str(i))
  R=0
  for j in range(M):
    R += int(str(i)[j])
  if a <= R <= b:
    count +=i
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(list(map(int, list(str(i))))) <= b]))

Submission status: Accepted

Solution code:
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    n, a, b = (int(x) for x in sys.stdin.read().split())
    total = 0
    for i in range(1, n+1):
        s = sum(list(int(x) for x in str(i)))
        if a <= s <= b: total += i
    print(total)

if __name__ == "__main__":
    # execute only if run as a script
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
ttl,a,b=0,0,0
L=[]
for i in range(1,N+1):
  L=list(map(str,str(i)))
  for j in L:
    a=a+int(j)
  if B>=a>=A:
    ttl=ttl+i
  a=0
  L=[]
print(ttl)

Submission status: Accepted

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

sm = 0

for i in range(1, N+1):
    digit = str(i)
    sm_t = 0
    for d in digit:
        sm_t += int(d)
    
    if sm_t >= A and sm_t <= B:
        sm += i

print(sm)

Submission status: Accepted

Solution code:
def main():
    N, A, B = map(lambda i: int(i), input().split())
    numbers = []
    for i in range(N):
        num = sum(list(map(lambda i: int(i), list(str(i + 1)))))
        if num >= A and num <= B:
            numbers.append(i + 1)

    print(sum(numbers))

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:
n,a,b=map(int,input().split())
s=0
for i in range(1,n+1):
    k=0
    m=i
    while m>0:
        k+=m%10
        m=m//10
    if a<=k<=b:
        s+=i
print(s)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
memo =[0]*37

def S(n):
  if n<10:
    return n
  else:
    return n%10+S(n//10)
for i in range(N+1):
  memo[S(i)] += i
print(sum(memo[A:B+1]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding=utf-8

if __name__ == '__main__':
    n, a, b = map(int, input().split())

    ans = 0
    li = []

    for i in range(n + 1):
        Cli = str(i)
        cnt = 0

        for j in range(len(Cli)):
            cnt = cnt + int(Cli[j])

        if a <= cnt <= b:
            ans = ans + i

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

total_sum = 0

for x in range(1, n+1):
    x_str = str(x)
    x_str = map(int, x_str)
    sum_dig = sum(x_str)
    if(a<=sum_dig and sum_dig<=b):
        total_sum+=x

print(total_sum)

Submission status: Accepted

Solution code:
n,a,b = map(int, input().split())
total = 0
for i in range(n+1):
    num = [int(d) for d in str(i)]
    if sum(num)>=a and sum(num)<=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):
  sumi = sum([int(num) for num in str(i)])
  if A <= sumi and sumi <= 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 = sum([int(d) for d in str(i)])
  if a <= num <= b:
    result += i
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
n_all = 0
for i1 in range(n+1):
    s_i1 = str(i1)
    s_sum = 0
    for i2 in s_i1:
        s_sum += int(i2)
    if a <= s_sum <= b:
        n_all += i1
print(n_all)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
n_list = [i for i in range(1, n+1)]
str_list = list(map(list, map(str, n_list)))
sum_list = [sum(map(int,str_list[j])) for j in range(n)]
T_list = [(k >= a and k<= b) for k in sum_list]
indices = [l for l, m in enumerate(T_list) if m == True]
ans = sum([n_list[n] for n in indices])
print(ans)

Submission status: Accepted

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

for i in range(n+1):
  sums = 0
  sums = sum(map(int,str(i)))
  if a<=sums<=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=0
    for j in str(i):
        x += int(j)
    if a<=x<=b:
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
def sumNumber(x: str):
    x_list = [x[i] for i in range(len(x))]
    x_list = list(map(int, x_list))
    x_sum = sum(x_list)

    if a <= x_sum and x_sum <= b:
        return int(x)
    else:
        return False


def judge():
    nl = [x for x in range(1, n + 1)]
    nl_str = list(map(str, nl))
    ans = list(map(sumNumber, nl_str))

    ans = [i for i in ans if i is not False]
    print(sum(ans))


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

# 5問目

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


def kakuketa_wa(x):
    sum = 0

    if x < 10:
        return x
    else:
        a = [int(j) for j in list(str(x))]
        for k in a:
            sum += k
        return sum


for i in range(1,n+1):
    if (a <= kakuketa_wa(i)) and (kakuketa_wa(i) <= b):
        d_sum += i


print(d_sum)

Submission status: Accepted

Solution code:
def digit_sum(n):
  return sum(map(int, str(n)))

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

count = 0
for n in range(N+1):
  if A <= digit_sum(n) <= B:
    count += n

print(count)

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))
    s = [int(j) for j in s]
    if a <= sum(s) <= b:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
x = [int(i) for i in input().split()]
ans = 0
for i in range(1,x[0]+1):
    tmp = sum([int(st) for st in str(i)])
    if x[1]<=tmp and x[2] >= tmp:
        ans += i
print(ans)

Submission status: Accepted

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

ans = 0

for i in range(1,x[0]+1):
  tmp = sum([int(st) for st in str(i)])
  if x[1] <= tmp and x[2] >= tmp:
    ans += i
    
print(ans)

Submission status: Accepted

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

N = int(N)
A = int(A)
B = int(B)

def digitSum(n):
	s = str(n)
	array = list(map(int,s))
	return sum(array)

total = int(0)

for x in range(N+1):
	if(A <= digitSum(x) and digitSum(x) <= B):
		total += x

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
N, A, B = tuple(int(num) for num in input().split())

sum = 0

for num in range(1, N+1):
  s = list(str(num))
  s_list = [int(i) for i in s]
  count = 0
  if len(s_list) > 1:
    for i in s_list:
      count = count + i
  else:
    count = s_list[0]
  if count >= A and count <= B:
    sum = sum + num
print(sum)

Submission status: Accepted

Solution code:
# 各位の値を足し算する処理
def sum_each_digit(n):
    total_each_digit = 0
    while n > 0:
        total_each_digit += n % 10
        n //= 10
    return total_each_digit


N, A, B = map(int, input().split())
target_total = 0    # 加算対象の数値の和

for n in range(1, N + 1):

    if A <= sum_each_digit(n) <= B:
        target_total += n

print(target_total)

Submission status: Accepted

Solution code:
# 各位の値を足し算する処理2
def sum_each_digit(n):
    total_each_digit = 0
    while n >= 1:
        total_each_digit += n % 10
        n //= 10
    return total_each_digit


N, A, B = map(int, input().split())
target_total = 0    # 加算対象の数値の和

for n in range(1, N + 1):

    if A <= sum_each_digit(n) <= B:
        target_total += n

print(target_total)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
ans = 0
for n in range(1, N+1):
  temp = 0
  for i in range(len(str(n))):
    temp += int(str(n)[i])
  if temp >= A and temp <= B:
    #print(n)
    ans += n
print(ans)

Submission status: Accepted

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

target_total = 0    # 加算対象の数値の和

for n in range(1, N + 1):
    total_each_digit = 0    # 各位の和      
    str_n = str(n)
    n_length = len(str_n)  # nの桁数
    
    for i in range(n_length):
        total_each_digit += int(str_n[i])

    if A <= total_each_digit <= B:
        target_total += n

print(target_total)

Submission status: Accepted

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

target_total = 0

for n in range(1, N + 1):
    total_each_digit = 0
    n_length = len(str(n))
    
    for i in range(n_length):
        total_each_digit += int(str(n)[i])
    if A <= total_each_digit <= B:
        target_total += n

print(target_total)

Submission status: Accepted

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

target_total = 0
total_each_digit = 0
n_length = 0

for n in range(1, N + 1):
    total_each_digit = 0
    n_length = len(str(n))
    
    for i in range(n_length):
        total_each_digit += int(str(n)[i])
    if A <= total_each_digit <= B:
        target_total += n

print(target_total)