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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ANS=0
for i in range(1,N+1):
    
    x=list(map(int,list(str(i))))

    if A<=sum(x)<=B:
        ANS+=i

print(ANS)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def digit_sum(num:int, base:int) -> int:

    if num < base:
        return num
    else:
        return digit_sum(int(num/base), base) + (num % base)
    
n,a,b = li()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def digitsum(n):
    s=str(n)
    array=list(map(int,list(s)))
    return sum(array)

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sumnum)

Submission status: Accepted

Solution code:
def answer(*inp):

    _in = inp[0].split()
    N = int(_in[0])
    A = int(_in[1])
    B = int(_in[2])

    total = 0

    for n in range(N):
        _sum = 0
        for i in str(n + 1):
            _sum += int(i)

        if A <= _sum <= B:
            total += (n + 1)

    print(total)

answer(input())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum(risuto))

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split(" "))
array=[]
for i in range(1,n+1):
    j=i
    s=0
    while(j>0):
        dig=j%10
        s=s+dig
        j=int(j/10)
    if a<=s<=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(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())
sum = 0
for i in range(n+1):
    isum = 0
    m = i
    while m != 0:
        isum += m%10
        m = m//10
    if isum >= a and isum <= b:
        sum += i
print(sum)

Submission status: Accepted

Solution code:
import math
import numpy as np

n, a, b = [int(i) for i in input().split()]
ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
def split_sum(number):
  number_split_string = list(str(number))
  number_split_int = [int(e) for e in number_split_string]
  return sum(number_split_int)
list_meet_condition = []
for i in range(1,N+1):
  if A <= split_sum(i) <= B:
    list_meet_condition.append(i)
print(sum(list_meet_condition))

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
sum_num = 0
for i in range(0, N + 1):
  num = i
  digit_list =[]
  while num > 0:
    digit_list.append(num%10)
    num //= 10
  if (A <= sum(digit_list)) and (sum(digit_list) <= B):
    sum_num += i
print(sum_num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

nsum = 0
ans = 0

for i in range(n):
    tmp = i + 1
    nsum = 0
    while True:
        nsum += tmp  % 10
        tmp = tmp // 10
        if tmp == 0:
            break

    if a <= nsum and nsum <= b:
        ans += (i + 1)


print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
index=1
allSum =0
while index<n+1:
    listS = list(str(index))
    index2 =0
    sum=0
    while index2< len(listS):
        sum+=int(listS[index2])
        index2+=1
    if sum > a-1 and sum < b+1:
        allSum+=index
    index+=1

print(allSum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, a, b = map(int, input().split())
cnt = 0

for i in range(N):
    list1 = [int(j) for j in str(i + 1)]
    if sum(list1) >= a and sum(list1) <= b:
        cnt += i + 1

print(cnt)

Submission status: Accepted

Solution code:
#AtCoder Beginner Contest 083 B Some Sums
n, a, b = map(int,input().split())


sums = 0

def sumStr(x):
    tmp = 0
    for i in range(len(str(x))):
        tmp += int((str(x))[i:i+1])
    return tmp

for i in range(n):
    sum = sumStr(i+1)
    if a <= sum  and sum <= b:
        sums = sums + i + 1


print(sums)

Submission status: Accepted

Solution code:
#AtCoder Beginner Contest 083 B Some Sums
#n, a, b = map(int,[input().split()])
list = input().split()
n = int(list[0])
a = int(list[1])
b = int(list[2])

sums = 0

def sumStr(x):
    tmp = 0
    for i in range(len(str(x))):
        tmp += int((str(x))[i:i+1])
    return tmp

for i in range(n):
    sum = sumStr(i+1)
    if a <= sum  and sum <= b:
        sums = sums + i + 1


print(sums)

Submission status: Accepted

Solution code:

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def judge(n):
    result = 0
    j = n
    for i in range(1, len(str(n)) + 1):
        result += j % 10
        j = int(j / 10)

    return result

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

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

    print(ans)

main()

Submission status: Accepted

Solution code:
# !/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    n, a, b = map(int, input().split())
    ans = sum([
        i for i in range(1, n + 1)
        if sum([int(d) for d in str(i)]) in range(a, b + 1)
    ])
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

N, A, B = [int(x) for x in stdin.readline().rstrip().split()]

ans = 0
for i in range(N + 1):
    num = i
    num_sum = 0

    while True:
        num_sum += num % 10
        num //= 10
        if num <= 0:
            break

    if A <= num_sum and num_sum <= B:
        ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1, n+1, 1):
  lists.append(i)

z = 0
for j in lists:
  h = str(j)
  x = 0
  for k in h:
    x += int(k)
  if x >=a and x <= b:
    z += j
print(z)

Submission status: Accepted

Solution code:
def summ(n):
    n_s = str(n)
    tmp = 0
    for i in n_s:
        tmp += int(i)
    return tmp

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

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

Submission status: Accepted

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

for num in range(1,n+1):
  tmp=num
  while(True):
    if num == 0:
      break
    sum+=num%10
    num/=10
    num=int(num)
    
  if sum>=a and sum<=b:
    total+=tmp
    
  sum=0
  
print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# vim: set fileencoding=utf-8:


def main():
    N, A, B = map(int, raw_input().split())
    # 10^4なので全探索
    ans = 0

    for i, _ in enumerate(xrange(N), 1):
        n = map(int, str(i))
        if A <= sum(n) <= B:
            ans += i

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def isInBetween(i, a, b):
  if i >= a and b >= i:
    return True
  return False

for i in range(1,n+1):
  if i < 10:
    if isInBetween(i, a, b):
      ans_nums.append(i)      
  elif i >= 10 and i < 100:
    second_d = int(i/10)
    first_d = i-second_d*10
    if isInBetween(second_d + first_d, a, b):
      ans_nums.append(i)
  elif i >= 100 and i < 1000:
    third_d = int(i/100)
    second_d = int((i-third_d*100)/10)
    first_d = i-second_d*10-third_d*100
    total = third_d + second_d + first_d
    if isInBetween(total, a, b):
      ans_nums.append(i)
  elif i >= 1000 and i < 10000:
    fourth_d = int(i/1000)
    third_d = int((i-fourth_d*1000)/100)
    second_d = int((i-third_d*100-fourth_d*1000)/10)
    first_d = i-second_d*10-third_d*100-fourth_d*1000
    total = fourth_d + third_d + second_d + first_d
    if isInBetween(total, a, b):
      ans_nums.append(i)
  else:
    if isInBetween(1, a, b):
      ans_nums.append(i)

print(sum(ans_nums))

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

print(answer)

Submission status: Accepted

Solution code:
N,a,b = (int(i) for i in input().split())
sum = 0
for i in range(N):
    order = 0
    temp = i+1
    while temp > 0:
        order += temp%10
        temp = (temp - (temp%10)) /10
    if order >= a and order <= b:
        sum += i+1
print(sum)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
N, A, B= map(int, input().split())
result = []
for i in range(1, N + 1):
    tmp = i
    digits_sum = 0
    while tmp > 0:
        digits_sum += tmp % 10
        tmp //= 10
    if A <= digits_sum <= B:
        result.append(i)
print(sum(result))

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
total_val = 0
for i in range(1, n+1):
    i_str = str(i)
    digits = list(i_str)
    sum_digit = sum([int(digit) for digit in digits])
    if sum_digit >= a and sum_digit <= b:
        total_val += i
print(total_val)

Submission status: Accepted

Solution code:
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    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)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
total = 0
for i in range(1,n+1):
    i_remember = i
    sum = 0
    for j in range(1, 6):
        if 10**(j-1) <= i <10**j:
            temp = 0
            for k in range(j,0,-1):
                temp = i // 10**(k-1)
                sum += temp
                i -= temp*(10**(k-1))
    if a <= sum <=b:
        total += i_remember
print(total)

Submission status: Accepted

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

ans = 0
for i in range(1,N+1):
  x = i
  y = 0
  while x > 0:
    y += x % 10
    x = x // 10
  if A <= y and y <= 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):
    j = list(str(i))
    sum_j = 0
    for k in j:
        sum_j += int(k)
    if A <= sum_j and sum_j <= B:
        cnt += i

print(cnt)

Submission status: Accepted

Solution code:
#83b
n,a,b=map(int,input().split())
n=[str(i) for i in range(1,n+1)]
ans=0

for i in n:
    temp=[int(x) for x in list(str(i)) ]
    temp=sum(temp)
    if a<=temp<=b:
        ans+=int(i)

print(ans)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
count=0
for i in range (1,N+1):
    data='%05d'%(i)
    data_add=int(data[0])+int(data[1])+int(data[2])+int(data[3])+int(data[4])
    if data_add>=A and data_add<=B:
        count+=i
print(count)

Submission status: Accepted

Solution code:
N, A, B =map(int, input().split())
m=0
for i in range(N+1):
    a=i//10000
    b=i//1000-10*a
    c=i//100-10*(i//1000)
    d=i//10-10*(i//100)
    e=i//1-10*(i//10)
    if A <= a+b+c+d+e <= B:
        m +=i
print(m)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,A,B = inpl()

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

Submission status: Accepted

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

count = 0

for i in range(num + 1):
    str_list = list(str(i))
    int_list = [int(s) for s in str_list]
    if a <= sum(int_list) <= b:
        count += i
print(count)

Submission status: Accepted

Solution code:

def digit_sum(n:int) -> int:
    res = n
    ans = 0
    while res>0:
        ans = ans + res%10
        res = res//10
        
    return ans

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

for i in range(1,N+1):
    if digit_sum(i) >= A and digit_sum(i) <= B:
        ans += i
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

count = 0

for i in range(1, N+1):
    digit_sum = sum(list(map(int, list(str(i)))))

    if A <= digit_sum <= B:
        count += i

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
cnt=0
for i in range(1,N+1):
    num1=i%10
    #print(num1)
    num2=int(i/10)%10
    num3=int(i/100)%10
    num4=int(i/1000)%10
    num5=int(i/10000)%10
    if A<=(num1+num2+num3+num4+num5)<=B:
        cnt+=i
    #print(cnt)
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
L = []
for i in range(1,N+1) :
    K = []
    a = str(i)
    for j in range(len(a)) :
        K.append(int(a[j]))
    b = sum(K)
    if A <= b <= B :
        L.append(i)
print(sum(L))
#print(L)

Submission status: Accepted

Solution code:
# 初見分からず
# 各桁数の取り出し方：
# 数値を文字列に変換→文字列を一つずつリストの要素として分離することで可能
n, a, b = map(int, input().split())

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
chk=0
ans=[]
for i in range(1,n+1):
    chk=i%10
    tmp=10000
    p=i
    for j in range(4):
        chk+=i//tmp
        i%=tmp
        tmp//=10
    if a<=chk<=b: ans.append(p)
    
print(sum(ans))

Submission status: Accepted

Solution code:
def digitsum(n):
    res = 0
    for i in range(5):
        res += (n//10**i)%10
    return res
n,a,b=map(int,input().split())
res=0
for i in range(1,n+1):
    if a<=digitsum(i)<=b:
        res += i
print(res)

Submission status: Accepted

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

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

print(SUM)

Submission status: Accepted

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

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

print(some_sum)

Submission status: Accepted

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

def main():
    #入力
    lists = list(map(int, input().split()))
    
    total_sum = 0

    #Nまでの数字の内，各桁の和がA以上B以下のものを足し合わせる
    for i in range(1, lists[0]+1):
        degit_sum = sum(map(int, str(i)))
        if degit_sum >= lists[1] and degit_sum <= lists[2]:
            total_sum += i

    print('{}'.format(total_sum))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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


def sum_digit(i):
    s = str(i)
    l = list(map(int, list(s)))
    return sum(l)


for i in range(n + 1):
    if a <= sum_digit(i) and b >= sum_digit(i):                                                                   
        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 = sum(map(int,list(str(i))))
    if(tmp >= A 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(n):
    o=list(str(i+1))
    c=0
    for j in o:
        c+=int(j)
    if a<=c<=b:ans+=(i+1)
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, list(str(i)))))
    if A <= X and X <= B:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num_list = input().split(" ")
num_list = list(map(lambda x: int(x), num_list))
N, A, B = num_list
out = 0

for n in range(1, N+1):
  n_sum = 0
  tmp_n = n
  
  while(True):    
    div, mod = divmod(tmp_n, 10)
    n_sum += mod
    if div == 0:
      break
    else:
      tmp_n = div
  
  if n_sum >= A and n_sum <= B:
    out += n
print(out)

Submission status: Accepted

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

ans = 0
for num in range(1, n + 1):
    s = sum([int(d) for d in str(num)])
    if s >= a and s <= b:
        ans += num

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# xの各位の和を求めるプログラム
def findSomeofDigits(x):
	s = 0
	while x > 0:
		s = s + x % 10
		x = x // 10
	return s

N,A,B = map(int,input().split())
c = 0
for i in range(N):
	s = findSomeofDigits(i+1)
	if A <= s and s <= B:
		c = c + i + 1
print(c)

Submission status: Accepted

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

total = 0
for n in range(N+1):
	numbers = list(str(n))
	sum = 0
	for part in numbers:
		sum += int(part)
	
	if A <= sum & sum <= B:
		total += n
		
print(total)

Submission status: Accepted

Solution code:
N, A, B = list(map(int, input().split()))
cnt = 0
for i in range(N + 1):
	seq = list(map(int, list(str(i))))
	x = sum(seq)
	if A <= x and x <= 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):
    digits = map(int, list(str(i)))
    sums = sum(digits)

    if a <= sums and sums <= b:
        ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC083B - Some Sums
def main():
    n, a, b = [int(x) for x in input().split()]

    m = 0
    for i in range(1, n+1):
        s = str(i)
        k = 0
        for j in s:
            k += int(j)

        if a <= k and k <= b:
            m += i

    print(m)
    

if __name__ == '__main__':
    main()

Submission status: Accepted

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