Problem:
 Score : 300 points    Problem Statement You are given an integer N . Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally "Seven-Five-Three numbers") are there?  Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:   When the number is written in base ten, each of the digits 7 , 5 and 3 appears at least once, and the other digits never appear.       Constraints  1 \leq N < 10^9  N is an integer.         Input Input is given from Standard Input in the following format:  N       Output Print the number of the Shichi-Go-San numbers between 1 and N (inclusive).        Sample Input 1 575      Sample Output 1 4  There are four Shichi-Go-San numbers not greater than 575 : 357, 375, 537 and 573 .       Sample Input 2 3600      Sample Output 2 13  There are 13 Shichi-Go-San numbers not greater than 3600 : the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577 .       Sample Input 3 999999999      Sample Output 3 26484

Solution (Python):
import itertools
a = int(input())

A = ['0', '3', '5', '7']
B = []
count=0
for i, j, k, l, m, n, o, p, q, r in itertools.product(A, A, A, A, A, A, A, A, A, A):
    ans= i + j + k + l + m + n + o + p + q + r
    ans = int(ans)
    if(ans <=a):
        ans = list(str(ans))
        if('0' not in ans and '3' in ans and '5' in ans and '7' in ans):
            count+=1
    else:
        break
print(count)

Solution (Python):
import itertools

def calc(nums, n, k):
    total = 0
    for i in range(k):
        total += nums[i] * n[i]
    return total

N = int(input())
k = len(str(N))

nums = [10 ** i for i in range(k)]
nums.reverse()

finish = False
count = 0
for i in range(3, k+1):
    if finish:
        break
    if i == k:
        flag = True
    else:
        flag = False
    for n in itertools.product([3,5,7], repeat=i):
        if 3 in n and 5 in n and 7 in n:
            if flag:
                if N < calc(nums, n, i):
                    finish = True
                    break
            count += 1
print(count)

Solution (Python):
import itertools

N = int(input())
nums = [3, 5, 7]
res = 0
for i in range(10):
  for balls in itertools.product(nums, repeat=i):
    num = ''
    if 3 in balls and 5 in balls and 7 in balls:
      for j in range(i):
        num += str(balls[j])
      if int(num) > N:
        break
      res += 1

print(res)

Solution (Python):
n = int(input())

def make753(s):
    count = 0
    if int(s) > n:
        return 0
    if all(s.count(i) > 0 for i in '753'):
        count += 1
    for i in '753':
        count += make753(s + i)
    return count

print(make753('0'))

Solution (Python):
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0'))

Solution (Python):
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c)>0 for c in '753') else 0
    
    for c in '753':
        ret += dfs(s+c)
    return ret
    
print(dfs('0'))

Solution (Python):
N = int(input())

def num(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += num(s+c)
    return ret

print(num('0'))

Solution (Python):
UP = int(1e9)
s = set()


def dfs(n, f3, f5, f7):
    if n > UP:
        return
    if f3 and f5 and f7:
        s.add(n)
    dfs(n * 10 + 3, True, f5, f7)
    dfs(n * 10 + 5, f3, True, f7)
    dfs(n * 10 + 7, f3, f5, True)


dfs(0, False, False, False)
l = list(s)
l.sort()
n = int(input())
ans = 0
for i in l:
    if i <= n:
        ans += 1
    else:
        break
print(ans)

Solution (Python):
UP = int(1e9)
s = set()
full = set('357')


def dfs(n):
    if n > UP:
        return
    if set(str(n)) == full:
        s.add(n)
    dfs(n * 10 + 3)
    dfs(n * 10 + 5)
    dfs(n * 10 + 7)


dfs(0)
l = list(s)
l.sort()
n = int(input())
ans = 0
for i in l:
    if i <= n:
        ans += 1
    else:
        break
print(ans)

Solution (Python):
N = int(input())


ans = 0

def dfs(x, flags):
  if x <= N:
    global ans
    if flags == 7:
      ans += 1
  if x >= N:
    return
  dfs(x * 10 + 7, flags | 4)
  dfs(x * 10 + 5, flags | 2)
  dfs(x * 10 + 3, flags | 1)

ans = 0
dfs(0, 0)
print(ans)

Solution (Python):
n = int(input())

def dfs(s):
    if int(s) > n:
        return 0
    ret = 0
    if all(s.count(c) > 0 for c in '753'):
        ret = 1
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0'))

Solution (Python):

Set753 = {7, 5, 3}
List753 = [7, 5, 3]

N = int(input())

def getDigitList(n):
    list = []
    while n>0:
        list.append(n%10)
        n //= 10
    list.reverse()
    if list==[]: list = [0]
    return list

def gen(n):
    if n>N: return []
    else:
        d = getDigitList(n)
        
        if set(d)==Set753: 
            result = [n]
        else:
            result = []
        for a in List753:  result += gen(n*10+a)
        return result
                
result = gen(0)

print(len(result))

Solution (Python):
import collections

n = int(input())
dq = collections.deque()
dq.append('3')
dq.append('5')
dq.append('7')
cnt = 0
while dq:
    v = dq.popleft()
    int_v = int(v)
    if int_v <= n:
        for c in '357':
            dq.append(v + c)
        if all([c in v for c in '357']):
            cnt += 1
print(cnt)

Solution (Python):
N = int(input())

def dfs(n, is3, is5, is7):
    if(n > N): 
        return 0
    ans = 0
    if(is3 and is5 and is7): ans += 1
    ans += dfs(n * 10 + 3, True, is5, is7)
    ans += dfs(n * 10 + 5, is3, True, is7)
    ans += dfs(n * 10 + 7, is3, is5, True)
    return ans

if __name__ == "__main__":
    print(dfs(0, False, False, False))