Problem:


Score : 200 points

Problem Statement

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

Constraints

1 \leq N \leq 10^4

1 \leq A \leq B \leq 36

All input values are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

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

Sample Input 1

20 2 5

Sample Output 1

84

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

Sample Input 2

10 1 2

Sample Output 2

13

Sample Input 3

100 4 16

Sample Output 3

4554



Sample input:
20 2 5


Sample output:
84

Submission status: Accepted

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

for i in range(1,N+1): # 実はrange(a,b)は、aからb-1まで　の数字を格納したリスト
    # 整数の各桁の和を計算するポイント
    a = str(i)          # 整数を文字列に変換する
    array = map(int, a) # 文字列の要素をすべて数値に変換してリスト化
    sum_ = sum(array)   # リストの要素の和を計算する（おわり）
    if A <= sum_ <= B:
        ans += i
        
print(ans)

Submission status: Accepted

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

ans = 0

for i in range(1,N+1):
    tmp = str(i)
    wa = 0
    for j in tmp:
        wa += int(j)
    if A <= wa and wa <= B:
        ans += i
        
print(ans)

Submission status: Accepted

Solution code:
import sys


lines = 1
inp = list()

for _ in range(lines):
    inp.append(sys.stdin.readline().strip())

inp = inp[0].split()
n = int(inp[0])
a = int(inp[1])
b = int(inp[2])

result = 0

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
tmp = 0
x = 0
s = 0
for n in range(1,N+1):
  x = n
  tmp = 0
  while (x > 0):
    tmp = tmp + (x % 10)
    x = x // 10
  if (A <= tmp <= B):
    s = s + n
print(str(s))

Submission status: Accepted

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

def check(n):
    each=list(str(n))
    total=0
    for i in each:
        total+=int(i)
    if total>=a and total<=b:
        return True
    return False

ans=0
for i in range(1,n+1):
    if check(i):
        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) :
	s = str(i)
	l = len(s)
	x = 0
	for j in range(l):
		x += int(s[j])
	if 	x >= a and x <= b:

		count += i
 
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for x in range(n+1):
    x_1 = x%10
    x_2 = (x%100)//10 + x_1
    x_3 = (x%1000)//100 + x_2
    x_4 = (x%10000)//1000 + x_3
    x_5 = (x%100000)//10000 + x_4
    if a<=x_1 and x_1<=b and x<10:
       ans += x
    if a<=x_2 and x_2<=b and 10<=x and x<100:
       ans += x
    if a<=x_3 and x_3<=b and 100<=x and x<1000:
       ans += x
    if a<=x_4 and x_4<=b and 1000<=x and x<10000:
       ans += x
    if a<=x_5 and x_5<=b and 10000<=x and x<=100000:
       ans += x

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
  sum = 0
  check = i + 1
  while (check > 0):
    sum = sum + check % 10
    check = check // 10
  
  if sum >= a:
    if sum <= b:
      count += (i+1)
      
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

    ans = 0

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

    print(ans)

Submission status: Accepted

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


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

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

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

ans = 0
for n in range(N+1):
  if digitSum(n)>=A and digitSum(n)<=B:
    ans += n
    
print(ans)

Submission status: Accepted

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

def solve(n):
    if n == 0:
        return 0
    else:
        temp = n % 10
        return temp + solve(n // 10)

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

for i in range(1, N+1):
    x = i
    judg = 0
    for ii in range(len(str(i))):
        judg += (x % 10)
        x = x // 10    
    if A<=judg and B>=judg:
        ans += i

print(ans)

Submission status: Accepted

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

for n in range(1,N+1):
    lis=list(str(n))
    lis=map(int,lis)
    tmp=sum(lis)
    if(A<= tmp and B >= tmp):
        total+=n
print(total)

Submission status: Accepted

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

ans = 0
for i in range(N+1):
    q = i
    jdg = 0
    for k in range(5):
        jdg += q%10
        q //= 10
    if A <= jdg and jdg <=B:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    def dig(x):
        s=str(x)
        return sum(int(c) for c in s)
    n,a,b=MI()
    ans=0
    for x in range(1,n+1):
        if a<=dig(x)<=b:ans+=x
    print(ans)

main()

Submission status: Accepted

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

for num in range(1, N+1):
    str_num = str(num)
    tmp = 0
    for char in str_num:
        char = int(char)
        tmp += char
    if tmp >= A and tmp <= B:
        ans += num

print(ans)

Submission status: Accepted

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


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

ans = 0
for i in range(1, N+1):
    count = 0
    for x in str(i):
        count += int(x)
    if count >= A and count <= B:
        ans += i
print(ans)

Submission status: Accepted

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

sum  = 0

for i in range (1, N+1):
	nyoki = 0
	stri = str(i)
	for j in range (1, len(stri)+1):
		nyoki = nyoki+int(stri[j-1])
	if nyoki >= A and nyoki <= B:
		sum = sum+i

print(sum)

Submission status: Accepted

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

ans = 0
for i in range(N+1):
    s = str(i)
    jdg = 0
    for k in range(len(s)):
        jdg += int(s[k])
    if A <= jdg and jdg <=B:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, a, b = map(int,input().split())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0
for i in range(1,n+1):
    s = 0
    q = i
    for j in range(5):
        r = q % 10
        s += r
        q //= 10
    
    if a <= s and s <= 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):
    tmp = list(str(i))
    for j in range(len(tmp)):
        tmp[j] = int(tmp[j])
    tmp = sum(tmp)
    if a <= tmp <= b:
        total += i
print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,a,b = map(int,input().split())
sums = 0
for i in range(1,N+1):
    moji = list(str(i))
    moji = [int(j) for j in moji]
    ans = sum(list(moji))
    
    if a <= ans and ans <= b:
        sums += i
print(sums)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
ans = 0
for i in range(1,N+1):
  K = str(i)
  if len(K) == 1:
    if A<=int(K[0])<=B:
      ans += i
  elif len(K) == 2:
    if A<=int(K[0])+int(K[1])<=B:
      ans += i
  elif len(K) == 3:
    if A<=int(K[0])+int(K[1])+int(K[2])<=B:
      ans += i
  elif len(K) == 4:
    if A<=int(K[0])+int(K[1])+int(K[2])+int(K[3])<=B:
      ans += i
  elif len(K) == 5:
    if A<=int(K[0])+int(K[1])+int(K[2])+int(K[3])+int(K[4])<=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 = 0
    j = i
    while i > 0:
        s += i % 10
        i //= 10
    if A <= s <= B:
        ans += j
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n,a,b = list(map(int,input().split()))
ret = 0
for i in range(1,n+1):
    sm = sum(map(int,str(i)))
    if a <= sm <= b:
        ret+=i
print(ret)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
count = 0
for i in range(n+1):
    x = str(i)
    num = 0
    for j in range(len(x)):
        num += int(x[j])
    if num >= a and num <= 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):
    k = i
    tmp = 0
    while k > 0:
        tmp += k % 10
        k = k // 10
    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(1, N + 1):
    str_i = str(i)
    digit_sum = 0
    for j in range(len(str_i)):
        digit_sum += int(str_i[j])
    if A <= digit_sum and digit_sum <= B:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n, a, b = map(int, input().split())
    answer = 0
    for i in range(1, n + 1):
        digit_sum = 0
        now = i
        while 0 < now:
            digit_sum += now % 10
            now //= 10
        if a <= digit_sum <= b:
            answer += i
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,x,y = inpl()
res = 0
for i in range(1,n+1):
    cnt = 0
    for xx in list(str(i)):
        cnt += int(xx)
    if x <= cnt <= y:
        res += i
print(res)

Submission status: Accepted

Solution code:
def main():
    N, a, b = (int(i) for i in input().split())
    ans = 0
    for i in range(1, N+1):
        S = str(i)
        cur = 0
        for s in S:
            cur += int(s)
        if a <= cur <= b:
            ans += i
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n, a, b = MAP()
ans = 0
for i in range(1, n + 1):
    arr = [int(j) for j in str(i)]
    tmp = 0
    for j in arr:
        tmp += 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(1, n+1):
    num = str(i)
    cnt = 0
    for j in range(len(num)):
        cnt += int(num[j])
    if a <= cnt <= b:
       ans += i
print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

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

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
N, A, B = map(int, input().split(" "))
s = 0

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

Submission status: Accepted

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

def digitSum(num):
    numToString = str(num)
    array = list(map(int, numToString))
    return sum(array)

ans = 0

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

Submission status: Accepted

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

ret = 0
for n in range(1, N+1):
  tmp_n = n
  tmp_cond = 0
  while tmp_n > 0:
    tmp_cond += tmp_n % 10
    tmp_n //= 10
  if A <= tmp_cond <= B:
    ret += n

print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

N,A,B = map(int, input().split())
total = 0
for i in range(1,N+1):
    sum = keta(i)
    if (sum >= A) and (sum <= B):
        total += i
print(total)

Submission status: Accepted

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

def sum(x):
  total = 0
  while x>0:
    num = x%10
    total +=num
    num=0
    x = int(x/10)
  
  return total
    
for i in range(1,n+1):
  if sum(i)>=a and sum(i)<=b:
    all +=i
  
print(all)

Submission status: Accepted

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

tmp = 0
sum = 0
ans = 0

for i in range(a+1):
  tmp = i
  sum = 0
  while tmp > 0:
    sum += tmp % 10
    tmp //= 10
  if b <= sum <= c:
#    print("i:" + str(i))
    ans += i
print(ans)

Submission status: Accepted

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

def get_sum(i):
    sum = 0
    while i > 0:
        sum += (i%10)
        i = int(i/10)
    return sum

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

print(cnt)

Submission status: Accepted

Solution code:
def nyu():
    num1,num2,num3 = input().split()
    #num2 = list(map(int,input().split()))
    num1 = int(num1)
    num2 = int(num2)
    num3 = int(num3)
    return num1,num2,num3

def check(N,A,B):
    sum_cnt=0
    sum = 0
    for n in range(N+1):
        sum = 0
    #     tmp_n = n
    #     sum += int(tmp_n/10000)
    #     tmp_n = tmp_n % 10000
    #     sum += int(tmp_n/10000)
    #     tmp_n = tmp_n % 1000
    #     sum += int(tmp_n/100)
    #     tmp_n = tmp_n % 100
    #     sum += int(tmp_n/10)
    #     tmp_n = tmp_n % 10
    #     sum += tmp_n
        n_str = str(n)
        l_n_str = list(n_str)
    #   print(l_n_str)
        for ln in l_n_str:
            sum += int(ln)

        if A<=sum and sum<=B:
#           print("n=",n,"sum=", sum)
            sum_cnt +=n
    print(sum_cnt)

N,A,B=nyu()
check(N,A,B)

Submission status: Accepted

Solution code:
# Problem: https://atcoder.jp/contests/abc083/tasks/abc083_b
# Python 2nd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
intm1 = lambda x: int(x) - 1
intp1 = lambda x: int(x) + 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def digitSum(target):
    result = 0
    strTarget = str(target)
    for j in range(0, len(strTarget)):
        result = result + int(strTarget[j])
    return result


def checker(target, fromNumber, toNumber):
    result = False
    x = digitSum(target)
    if fromNumber <= x :
        if  x <= toNumber :
            result = True
    return result


def solver(maxNumber, fromNumber, toNumber):
    result = 0
    for j in range(1, maxNumber + 1):
        if checker(j, fromNumber, toNumber):
#            print("{} is check!".format(j))
            result = result + j
    # algorithm
    return result


if __name__ == "__main__":
    N, A, B = MI()
    print("{}".format(solver(N, A, B)))

Submission status: Accepted

Solution code:
data = list(map(int,input().split()))
n = data[0]
a = data[1]
b = data[2]
ans = 0
a1 = 0
a2 = 0
a3 = 0
a4 = 0
a5 = 0

for i in range(n+1):
  base = str(i)
  if i >= 10000:
    a1 = base[0]
    a2 = base[1]
    a3 = base[2]
    a4 = base[3]
    a5 = base[4]
  elif i >= 1000:
    a1 = base[0]
    a2 = base[1]
    a3 = base[2]
    a4 = base[3]
  elif i >= 100:
    a1 = base[0]
    a2 = base[1]
    a3 = base[2]
  elif i >= 10:
    a1 = base[0]
    a2 = base[1]
  elif i >= 0:
    a1 = base[0]
  
  
  total = int(a1)+int(a2)+int(a3)+int(a4)+int(a5)
  if a <= total <= 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):
  s = str(i + 1)
  S = 0
  for j in range(len(s)):
    S += int(s[j])
  if A <= S and S <= B:
    ans += i + 1
print(ans)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
L = []
def wa(x):
    s = 0
    while x > 0:
        s += x % 10
        x = int(x / 10)
    return s

for i in range(N + 1):
    if A <= wa(i) <= B:
        L.append(i)
        
print(sum(L))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
# Written by NoKnowledgeGG @YlePhan
 
#import math
#mod = 10**9+7
 
 
 
def main():
  n,a,b = map(int,input().split())
  
  ans = 0
  for t in range(1,n+1):
    tmp = 0
    v = t
    while True:
      tmp += t % 10
      if t // 10 != 0:
        t //= 10
      else:
        break
    if a <= tmp <= b:
      ans += v
  print(ans)
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
n,a,b=list(map(int,input().split()))
ans=0
for i in range(1,n+1):
  i1=i//10000
  i2=i//1000%10
  i3=i//100%10
  i4=i//10%10
  i5=i%10
  if i1+i2+i3+i4+i5>=a and i1+i2+i3+i4+i5<=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 c in str(i):
    x+=int(c)
  if A <= x <= B:
    ans+=i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def f(num):
    s = 0
    while num != 0:
        s += num % 10
        num //= 10 
    return s

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Problem: https://atcoder.jp/contests/abc083/tasks/abc083_b
# Python  1st Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def int2ketanowa(No):
    result = 0
    noStr = str(No)
    nolen = len(noStr)
    for j in range(0,nolen):
        result = result + int(noStr[j])
    return result

def solver(maxNum, upperNum, lowerNum):
    result = 0
    for j in range(1,maxNum+1,+1):
        sumKeta = int2ketanowa(j)
        if upperNum <= sumKeta and sumKeta <= lowerNum:
            result = result + j
    return result


if __name__ == "__main__":
    N, A, B = MI()
    print("{}".format(solver(N, A, B)))

Submission status: Accepted

Solution code:
n, a, b = [int(x) for x in input().split()]
res = 0
for i in range(1, n + 1):
  s = str(i)
  cc = 0
  for j in s:
    cc += int(j)
  res += i * (a <= cc <= b)
print(res)

Submission status: Accepted

Solution code:
# ABC083 B

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

    sums = []

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

INF = float('inf')


def number2digits(number):
    return list(map(int, str(number)))


def sum_of_digits(number):
    sum = 0
    while number > 0:
        sum += number % 10
        number //= 10
    return sum


def main():
    N, A, B = map(int, input().split())
    ans = 0
    for number in range(1, N+1):
        total = sum_of_digits(number)
        if A <= total <= B:
            ans += number

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

INF = float('inf')


def number2digits(number):
    return list(map(int, str(number)))

def main():
    N, A, B = map(int, input().split())
    ans = 0
    for number in range(1, N+1):
        num_digits_list = number2digits(number)
        total = 0
        for i in num_digits_list:
            total += int(i)
        if A <= total <= B:
            ans += number

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,A,B = [int(x) for x in input().split()]
ans = 0
def douka(a):
  wa = 0
  for i in range(4,-1,-1):
    if a // (10**i) == 0:
        continue
    wa += a//(10**i)
    a -= (a//(10**i))*(10**i)
  return wa
for i in range(1,N+1):
    if A <= douka(i) and douka(i) <= B:
      ans += i
print(ans)

Submission status: Accepted

Solution code:
# coding: UTF-8

def Totalsum(i):
    sum = 0
    while(i > 0):
        sum += i % 10
        i = i // 10
    return sum

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

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
target,min_t,max_t=(int(x) for x in input().split())
al=[]
for i in range(target+1):
  ii = sum(list(map(int,str(i))))
  if min_t <= ii <= max_t:
      al.append(i)
print(sum(al))

Submission status: Accepted

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

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

Submission status: Accepted

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

#各桁の合計を求める
def dsum(n): 
    s = str(n)
    array = list(map(int, s))
    return sum(array)

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

print(count)

Submission status: Accepted

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

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

print(count)