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())

# 各位の和
sum_digit = 0
# 各位の和がA以上B以下の数の和
sum = 0

for i in range(N + 1):
    s = str(i) # 数値iを文字列sに変換
    for j in range(len(s)):
        sum_digit += int(s[j])
    if sum_digit >= A and sum_digit <= B:
        sum += i
    # sum_digitの初期化
    sum_digit = 0

print(sum)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

#s = [0,0,0]
#s[0] = int(input/100)
#s[1] = int(input/10 - s[0]*10)
#[2] = int(input%10)



sum = 0
temp=0
tempy=0
#flag = 0

for i in range(1, N+1): #loop for N
  
  result = 0
  temp = i
  
  while(1):
    result += (int)(temp%10)
    tempy = (int)(temp/10)
    if tempy==0:
      break
    else:
      temp = tempy
  
  if (result >= A) and (result <= B):
    sum += i
    #print(i)
  
  #####
  #revB
  #####
  #p = i%10 #1桁目
  #tempy = (int)(i/10)
  #
  #if tempy > 0:
  #  q = tempy%10 #2桁目
  #  temp = (int)(tempy/10)
  #  tempy = temp
  #else:
  #  q=0
  #  r=0
  #  s=0
 # 
  #if tempy > 0:
  #  r = tempy%10 #3桁目
  # temp = (int)(tempy/10)
  #  tempy = temp
  #else:
  #  r=0
  #  s=0
  
  #if tempy > 0:
  #  s = tempy%10 #4桁目
  #else:
  #  s=0
  
  #####
  #revA
  #####
  #s = (int)(i/1000)
  #r = (int)(i/100-10*s)
  #q = (int)(i/10-10*r-100*s)
  #p = (int)(i%10)
  #print(p)
  #print(q)
  #print(r)
  #print(s)
  
  #temp = p+q+r+s
  #if (temp >= A) and (temp <= B):
  #  sum += i
  #  print(i)

  
#judge

#print('result')
#print(A)
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
result = 0
for i in range(1,n+1):
    if a <= sum(map(int,list(str(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)
  work=0
  for j in range(len(s)):
    work+=int(s[j])
  if work>=a and work<=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):
	s = str(i)
	array = list(map(int,s))
	sa = sum(array)
	if sa >= a and sa <= 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):
  temp = sum(list(map(int, list(str(i)))))
  if a <= temp <= 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 = eval("+".join(str(i)))
    if a <= s and s <= b:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ary = []
c = []
for i in range(n):
	num = str(i+1)
	ary = list(map(int, num))
	if(sum(ary) >= a and sum(ary) <= b):
		c.append(i+1)

print (sum(c))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def sum_digits(digits):
  return sum(int(digit) for digit in str(digits))
  
for i in range(1, n+1):
  total_digits = sum_digits(i)
  if total_digits >= a and total_digits <= b:
    total += i
  
print(total)

Submission status: Accepted

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

def sum_digits(digits):
  return sum(int(digit) for digit in str(digits))
  
for i in range(1, n+1):
  if sum_digits(i) >= a and sum_digits(i) <= b:
    total += i
  
print(total)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
total = 0
for i in range(1, n+1):
  total_digit = 0
  j = i
  while True:
    total_digit += j % 10
    j //= 10
    if j == 0:
      if total_digit >= a and total_digit <= b:
        total += i
      break
print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for ai in range(a+1):
  x = sum(list(map(int,str(ai))))
  if b <= x and c >= x:
    res += ai

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

for i in range(1,n+1):
	num_str = list(str(i))
	some_sum = 0
	for num in num_str:
		some_sum += int(num)
	if a <= some_sum <= b :
		numbers.append(i)
print(sum(numbers))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def findSumOfDigits(x):
	sum=0
	while x>0:
		sum+=int(x%10)
		#sum+=x%10
		x=int(x/10)
	return sum
	#sum+=x%10の場合、return int(sum)



n,a,b=map(int,input().split())
total=0
total_2=0
for i in range(1,n+1):
	total=findSumOfDigits(i)
	if a<=total<=b:
		total_2+=i

print(total_2)

Submission status: Accepted

Solution code:
#各桁の和を計算する関数
def findSumOfDigits(n):
  sum = 0
  while( n > 0):
    sum += int(n) % 10
    n = int(n) / 10
  return int(sum)

N,A,B = [int(i) for i in input().rstrip().split()]

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

print(total)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

ans = 0

for n in range(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())

ans = 0

def sum_of_decimals(n):
    return sum(int(c) for c in str(n))

for n in range(N+1):
    if A <= sum_of_decimals(n) <= B:
        ans += n

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def digitSum(n):
	s = str(n)
	array = list(map(int, s))
	return sum(array)
count = 0
for i in range(n):
	temp = digitSum(i+1)
	if (temp >= a) and (temp <= b):
		count = count + i+1


print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/python3

import sys
# input = sys.stdin.readline
sys.setrecursionlimit(100000)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7

#N = int(input())
#A = [int(x) for x in input().split()]
#V = [[0] * 100 for _ in range(100)]

N,A,B = [int(x) for x in input().split()]

def f(n):
    r = 0
    for s in str(n):
        r += int(s)
    return r

ans = 0
for i in range(1,N+1):
    s = f(i)
    if A <= s and s <= B:
        ans += i

print(ans)

Submission status: Accepted

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC083
#B - Some Sums

#入力
n, a, b  = map(int, input().split())
ans = 0

for i in range(n+1):
    c = sum(list(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
for i in range(1,N+1):
  s=list(map(int,str(i)))
  s=sum(s)
  if A<=s and 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):
    c = 0
    j = 4
    num = i
    while j >= 0:
        temp = num//10**j
        c += temp
        num -= temp*(10**j)
        j -= 1
    if A <= c <= B:
        ans += i
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(total)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
import math
def wa(x):
  keta = math.floor(math.log10(x))+1
  count = 0
  for i in range(keta):
    count += (x//(10**i))%10
  return count
s = 0
for i in range(a, n+1):
  if a<=wa(i) and wa(i)<=b:
    s += i
print(s)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
total=0
def sum_each(c):
    c=int(c)
    c2=list(str(c))
    total=0
    for i in range(len(c2)):
        total+=int(c2[i])
    return total

for i in range(1,n+1):
    if a<=sum_each(i)<=b:
        total+=i
print(total)

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(list(map(int,str(i)))) <= b))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = 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())

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

print(ans)

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 n in range(N + 1):
  if A <= sum(list(map(int, str(n)))) <= B:
    ans += n
print(ans)

Submission status: Accepted

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

def k(N):
    sum = 0
    while N>0:
        sum += N%10
        N = N//10
    return sum

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,A,B = [int(x) for x in  input().split()]
ans =0

for i in range(1,N+1):
        a=i%10
        b=(i//10)%10
        c=(i//100)%10
        d=(i//1000)%10
        e=(i//10000)%10
    
        if A<=(a+b+c+d+e)<=B :
            ans +=i
print(ans)

Submission status: Accepted

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

ans = 0

def keta(N):
    sum = 0
    while N>0:
        sum += N%10
        N = N//10
    return sum

for i in range(1,n+1):
    if a<=keta(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):
    keta = list(str(i))
    count = 0
    for j in keta:
        count += int(j)

    if count >= A and count <= 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):
    tmp = 0
    num = i
    while num != 0:
        tmp += num % 10
        num = int(num / 10)
    if tmp >= a and tmp <= b:
        ans += i
    else:
        continue
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0
for i in range(1,n+1):
        tmp = 0
        for j in range(len(str(i))):
                tmp += int(str(i)[j])
        if a <= tmp <= 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):
  sum_i = sum([int(s) for s in str(i)])
  if A <= sum_i <= B:
    ans += i
print(ans)

Submission status: Accepted

Solution code:
import math

n, a, b= map(int, input().split())  #1行に複数の入力値を取得し、異なる変数に入れる

def digit(n):	#ある整数の１の位を導出する関数を定義
	ans = n % 10
	return ans

total = 0

for i in range (1, n + 1):      #１からNまでの全ての整数について探索
	ans = digit(i)             #ansにiの一の位を追加    834 → 8
	x = math.floor(i / 10)     #xにiの十の位以降を代入、一の位は切り捨て   834 → 83

	while x != 0:              #834→83→8→0のように、０になるまで上記の作業を繰り返す
		ans = ans + digit(x)
		x = math.floor(x / 10)

	if 	a <= ans <= b:         #各桁の値の合計がa以上b以下ならtotalに追加
		total = total + i

print(total)

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 += i
print(ans)

Submission status: Accepted

Solution code:
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, A, B] = string_to_int(inputs[0])

    total_sum = 0
    for i in range(1, N+1):
        sum_num = reduce(lambda acc, x: acc + int(x), str(i), 0)
        if sum_num >= A and sum_num <= B:
            total_sum += i
    return total_sum


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):
    print(sum([check_sum_digit(num, A, B) for num in range(N + 1)]))
    return

def check_sum_digit(num: int, A: int, B: int):
    sum = sum_digit(num)
    return num if sum >= A and sum <= B else 0

def sum_digit(num: int):
    return sum([int(n) for n in str(num)])

# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def SumOfDigits(s):
    return sum(map(int, s))

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

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

print(ans)

Submission status: Accepted

Solution code:
N,A,B=[int(s) for s in input().split()]
kotae=0
for i in range(1,N+1):
  x=i
  count = 0
  while x>0:
    count += x % 10
    x = x // 10
  if A<=count and count<=B:
    kotae += i
print(kotae)

Submission status: Accepted

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

total_sum = 0
for i in range(1, N+1):
    num = i
    sum = 0
    while num > 0:
        sum += num % 10
        num //= 10
    if A <= sum <= B:
        total_sum += i
print(total_sum)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n, a, b = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    for i in range(1, n + 1):
        s = str(i)
        t = 0
        for j in range(len(s)):
            t += int(s[j])
        if a <= t <= b:
            cnt += i
    print(cnt)


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
t=0
for n in range(1,N+1):
    #print(n)
    m=n
    c=0
    while m//10>0:
        c+=m%10
        m=m//10
    c+=m
    #print(c)
    if A<=c and c<=B:
        t+=n
print(t)

Submission status: Accepted

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

ans = 0
for i in range(1,N+1):
    i1 =  i%10
    i10 = (i%100 -i1)/10
    i100 = (i%1000 -i1 - 10*i10)/100
    i1000 = (i%10000 -i1 - 10*i10-100*i100)/1000
    i10000 = (i -i1 -10*i10 -100*i100 - 1000*i1000)/10000
    if A<=i1+i10+i100+i1000+i10000<=B:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
N = range(1, n+1)
ans = 0
for n in N:
    s = 0
    q, mod = divmod(n, 10)
    s += mod
    q, mod = divmod(q, 10)
    s += mod
    while q != 0:
        q, mod = divmod(q, 10)
        s += mod
    if a <= s and s <= b:
        ans += n
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def digit(n):
    cnt=0
    v=str(n)
    for j in range(len(v)):
        cnt+=int(v[j])
    return cnt

for i in range(n+1):
    tmp =int(digit(i))
    if tmp>=a and tmp<=b:
        sum+=i

print(sum)

Submission status: Accepted

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

if __name__ == '__main__':
    print(solve())

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())
count = 0
for i in range(1,N+1):
    if A<=sum(list(map(int, str(i))))<=B:
        count += i
print(count)

Submission status: Accepted

Solution code:
def hoge(x):
    a = x
    ans = 0
    while True:
        if a//10 == 0:
           ans += a
           break
        else:
            ans += a%10
            a = a//10
    return ans

n,a,b  = map(int,input().split())
ans = 0
for i in range(1,n+1):
    if a <=  hoge(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):
  if a <= sum(map(int,str(i))) <= b:
    s += i
print(s)

Submission status: Accepted

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

ans=0
for i in range(1,n+1):
    c=i
    total=0
    for j in range(5):
        total +=(i%10)
        i =i//10
        
    if total >= a and total <= b:
        ans +=c
        
print(ans)

Submission status: Accepted

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

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

    print(s)

bb083()

Submission status: Accepted

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

def check(x,A,B):
    xp=x
    _sum=0
    while x>0:
        _sum+=x%10
        x=x//10
    return True if A<=_sum<=B else False

n=1
ans=0
while n<=N:
    ans+=n if check(n,A,B) else 0
    n+=1
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 += i
print(ans)

Submission status: Accepted

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

N,A,B = map(int,input().split())
ans = 0
for i in range(1,N+1):
    sd = sumdigit(i)
    if A <= sd and sd <= B:
        ans += i

print(ans)

Submission status: Accepted

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

res = 0
for i in range(0, 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())
s = 0
for i in range(1,N+1):
    if A <= sum([int(l) for l in list(str(i))]) <= B:
        s += i
print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for num in range(1, N+1):
    num_10000 = num // 10000
    num_1000 = (num - 10000*num_10000) // 1000
    num_100 = (num - 10000*num_10000 - 1000*num_1000) // 100
    num_10 = (num - 10000*num_10000 - 1000*num_1000 - 100*num_100) // 10
    num_1 = num - 10000*num_10000 - 1000*num_1000 - 100*num_100 - 10*num_10
    sum = num_1 + num_10 + num_100 + num_1000 + num_10000
    if A <= sum <= B:
        result += num
        
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b = map(int, 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:
def find_sum_of_digits(n):
    total = 0
    while n > 0:
        total += n % 10
        n //= 10
    return total


[N, A, B] = map(int, input().split())
ret = 0
for n in range(1, N + 1):
    total = find_sum_of_digits(n)
    if A <= total and total <= B:
        ret += n
print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

l = []
l = list(map(int, input().split()))
N = l[0]
minnum = l[1]
maxnum = l[2]
sumnum = 0
dsum = 0
        
for i in range(N + 1):
  dsum = sumdigit(i)
  if minnum <= dsum <= maxnum:
    sumnum += i
  
print(sumnum)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n + 1):
    s = 0
    for j in str(i):
        s += int(j)
    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(a,n+1):
    c=0
    c+=i%10
    d=i//10
    while d>0:        
        c+=d%10
        d=d//10
    if a<=c<=b:ans+=i
print(ans)

Submission status: Accepted

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

ans = 0
for val in range(n):
    # 和を計算
    tmp = 0
    for i in str(val):
        tmp = tmp + int(i)

    if tmp >= a and tmp <= b:
        ans = ans + val

print(ans)

Submission status: Accepted

Solution code:
from functools import reduce
n = list(map(int,input().split()))
ans = 0
for i in range(n[0]+1):
  s = list(map(int,str(i)))
  sum = reduce(lambda a,b: a+b, s)
  if n[1]<= sum and sum <= n[2]:
    ans+=i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(s)

Submission status: Accepted

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

print(s)

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())
array = []
for i in range(n+1):
    c = digitSum(i)
    if c >= a and c <= b:
        array.append(i)
print(sum(array))

Submission status: Accepted

Solution code:
n,a,b =map(int,input().split())
ans = 0
for i in range(1,n+1):
    # print(i)
    # print(list(str(i)))
    s = sum(int(j) for j in list(str(i)))
    # print(s)
    # print(a <= s and s <= b)
    if a <= s and 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):
  j = i
  su = 0
  while(j > 0):
    k = j % 10
    su += k
    j = j // 10
  if(su >= a and su <= 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):
    n_s = str(i)
    n_sum = 0
    for j in range(len(n_s)):
        n_sum += int(n_s[j])
    if a <= n_sum and n_sum <= b:
        count += i

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
def summ(X):
  a = X//10000
  b = (X - a*10000)//1000
  c = (X - a*10000 - b*1000)//100
  d = (X - a*10000 - b*1000 - c*100)//10
  e = X - a*10000 - b*1000 - c*100 - d*10
  return a+b+c+d+e
C = []
for i in range(1,N+1):
  if A <= summ(i) <= B:
    C.append(i)
print(sum(C))

Submission status: Accepted

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

Submission status: Accepted

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

def s(x):
  if x < 10:
    return x
  return x%10+s(x//10)

M = [0] * 37

for i in range(1,N+1):
  M[s(i)] += i
  
print(sum(M[A:B+1]))

Submission status: Accepted

Solution code:
def s(n):
    sum = 0
    while True:
        sum += n % 10
        if n < 10:
            break
        n = n//10
    return sum


def calc(n, a, b):
    sum = 0
    for i in range(1, n+1):
        k = s(i)
        if a <= k <= b:
            sum += i
    return sum


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

Submission status: Accepted

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

ans=0
count=0
for n in range(N+1):
  d_sum=0
  count=n
  while n>=1:
    d_sum=d_sum+n%10
    n=n//10
  if A <= d_sum <= B:
    ans=ans+count
    
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

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

nums = range(1,n + 1)

ans = 0

for num in nums:
    sum = 0
    sum += num % 10
    wari = num // 10
    
    while wari > 0:
        sum += wari % 10
        wari = wari // 10
    
    if sum >= a and sum <= b:
        ans += num

print(ans)