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



Sample input:
575


Sample output:
4

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

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

print(dfs("0"))

Submission status: Accepted

Solution code:
N=int(input())

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

print(dfs(""))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    Numbers = []
    def iter(s, i, n):
        if i == n:
            if ( s.find('3') >= 0 and s.find('5') >= 0 and s.find('7') >= 0 ):
                Numbers.append(int(s))
        else:
            iter(s+"3", i+1, n)
            iter(s+"5", i+1, n)
            iter(s+"7", i+1, n)

    N = int(lines.pop(0))
    for digit in range(3, len(str(N))+1):
        iter("",0, digit)

    print(len(list((filter(lambda x: x <= N, Numbers)))))
    #print(Numbers)

#
# main
#

# 1. use list instead of stdin

#contents = '''\
#575\
#'''
#lines = contents.split('\n')

# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Accepted

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

from itertools import product

def main():
  n = int(input())
  length_of_n = len(str(n))

  # length_of_n - 1 桁の時の七五三数の合計
  _sum = sum( [3**(i) - 3*(2**(i)) + 3*1 for i in range(3, length_of_n)] )

  # length_of_n 桁 かつ n 以下の七五三数
  for x in product(*([('3', '5', '7')]*length_of_n)):
    x = ''.join(x)
    if int(x) <= n and all([c in x for c in list('357')]):
      _sum += 1
  print(_sum)


  pass

if __name__=='__main__':
  main()

Submission status: Accepted

Solution code:
n=int(input())


L=[3,5,7]

def dfs(s):
    count=0
    for i in L:
        p=s*10+i
        if p<=n:
            if set([int(j) for j in str(p)])==set(L):
                count+=dfs(p)+1 #条件を満たしているので+1
            else:
                count+=dfs(p)
    return count

print(dfs(0))

Submission status: Accepted

Solution code:
N = int(input())

def dfs(s): # 文字列 s で始まる七五三数の個数
	if int(s) > N:
		return 0
	ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
	for c in '753':
		ret += dfs(s + c)
	return ret

print(dfs('0'))

Submission status: Accepted

Solution code:
import itertools
N= input()
Number=int(N)
count=[]
x=0
n=3
count=0
def check (S):
    S=str(S)
    if S.count('3')!=0 and S.count('5')!=0 and S.count('7')!=0 and int(S)<=Number:
        return 1

def dfs(x):
    global count
    if check(x)==1:
        count+=1
    if x<=Number:
        dfs(10*x+3)
        dfs(10*x+5)
        dfs(10*x+7)


dfs(0)
print(count)

Submission status: Accepted

Solution code:
N = int(input())
 
def abc114_c(s):
  if(int(s) > N):
    return 0
  if(all(s.count(c) > 0 for c in "753")):
    ans = 1
  else:
    ans = 0
  for c in "753":
    ans += abc114_c(s+c)
  return ans
print(abc114_c("0"))

Submission status: Accepted

Solution code:
import copy
n = int(input())
arr_ori = ["3", "5", "7"]
arr_tmp = ["3", "5", "7"]
arr_all = ["3", "5", "7"]
arr_753 = []
# arr_tmp = ["357", "375", "537", "573", "735", "753"]

for i in range(1, 9):
    for i in arr_ori:
        for j in arr_all:
            arr_tmp.append(i + j)
    arr_all = copy.deepcopy(arr_tmp)

arr_all = list(set(arr_all))

for i in range(len(arr_all)):
    if "3" in arr_all[i]:
        if "5" in arr_all[i]:
            if "7" in arr_all[i]:
                arr_753.append(arr_all[i])

arr_753 = [int(i) for i in arr_753]
arr_753 = sorted(arr_753)

for i in range(len(arr_753)):
    if int(arr_753[i]) > n:
        print(i)
        break
    elif i == len(arr_753)-1:
        print(i + 1)
        break

Submission status: Accepted

Solution code:
import math

n = 0
res = 0


def append(ds, r):
    global n, res
    if r == 0:
        if "3" in ds and "5" in ds and "7" in ds and int("".join(ds)) <= n:
            res += 1
        return
    for d in "357":
        append(ds + [d], r - 1)


def main():
    global n, res
    n = int(input())
    if n < 357:
        print(0)
        return
    r_max = int(math.log10(n)) + 1
    for r in range(3, r_max + 1):
        append([], r)
    print(res)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

def abc114_c(s):
  if(int(s) > N):
    return 0
  if(all(s.count(c) > 0 for c in "753")):
    ans = 1
  else:
    ans = 0
  for c in "753":
    ans += abc114_c(s+c)
  return ans
print(abc114_c("0"))

Submission status: Accepted

Solution code:
N = int(input())

n = 0
while N//(10**n)>0:
    n += 1

    
l = [3,5,7]

ans = 0

while l[0]<=10**n:
    m = []
    for i in l:
        m.append(i*10+3)
        m.append(i*10+5)
        m.append(i*10+7)
    for i in m:
        if i <= N and len(set(list(str(i))))==3:
            ans += 1
    l = m[:]

print(ans)

Submission status: Accepted

Solution code:
import itertools

N = int(input())
d = len(str(N))
choices = [7, 5, 3]

c=0
for _d in range(1, d+1):
    pats = list(itertools.product(choices, repeat=_d))
    for pat in pats:
        if not (7 in pat and 5 in pat and 3 in pat):
            continue

        n = 0
        for p in pat:
            n = 10*n + p
        if n <= N:
            c += 1
print(c)

Submission status: Accepted

Solution code:
from itertools import product
n=int(input())
ans=0

for l in range(1,11):
    for p in product('357',repeat=l): #3,5,7を組み合わせた要素数lのタプルを生成
        v=''.join(p) #p内の要素を結合
        u=v
        if '3' in v and '5' in v and '7' in v and int(u)<=n:
            ans+=1
print(ans)

Submission status: Accepted

Solution code:
from itertools import product

N = int(input())

ans = 0
for i in range(1,11):
  for fst in product(['5','7','3'], repeat = i):
    num = "".join(fst)
    if('5' in num and '7' in num and '3' in num and int(num) <= N):
      ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools
import math

n = input()
if(int(n)<357):
    print(0)
    exit()

ans = 0

for i in range(3,len(n)+1):
    if len(n) == i:
        for v in itertools.product(['3','5','7'],repeat=i):
            if '3' in v and '5' in v and '7' in v:
                if int(''.join(v)) <= int(n):
                    ans += 1
    else:
        ans += 3 ** i - 2 ** i * 3 + 3
print(ans)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
digits = [3, 5, 7]


def get_A_product(digits, N):
    A = []
    flag = False
    p = 3
    while True:
        for tup in itertools.product(digits, repeat=p):
            a = int("".join(list(map(str, tup))))
            if a > N:
                flag = True
                break
            A.append(a)
        if flag:
            break
        p += 1
    return A


count = 0
A = get_A_product(digits, N)
for a in A:
    if all(str(a).count(c) > 0 for c in '753'):
        count += 1
print(count)

Submission status: Accepted

Solution code:
n = int(input())

def next(x):
    if(x==""):
        return "3"
    if(x[-1]=="3"):
        return x[0:-1]+"5"
    if(x[-1]=="5"):
        return x[0:-1]+"7"
    if(x[-1]=="7"):
        return next(x[0:-1])+"3"

cnt=0
a = "3"
while(int(a) <= n):
    if all([c in a for c in "753"]):
        cnt += 1
    a = next(a)

print(cnt)

Submission status: Accepted

Solution code:
n=int(input())

def f(s):
    if int(s)>n:
        return 0
    elif all(s.count(c)>0 for c in '753'):
        t=1
    else:
        t=0
    for a in '753':
        t+=f(s+a)
    return t

print(f('0'))

Submission status: Accepted

Solution code:
N = int(input())
r=0
n=0
d={"1":3,"2":5,"3":7}
while True:
    n+=1
    n2 = n
    l=[]
    while n2 >= 4 :
        l.append(str(n2 % 4) )
        n2 //= 4
    l.append(str(n2))
    if "0" in l:
        continue
    w=0
    m=0
    for k in l:
        m +=  d[k]*10**w
        w += 1
    if m<=N and "1" in l and "2" in l and "3" in l:
        r += 1

    elif m>N:
        break

print(r)

Submission status: Accepted

Solution code:
n=int(input())

def dfs(s):
    if int(s)>n:
        return 0
    if all(s.count(c)>0 for c in "753"):
        a=1
    else:
        a=0

    for c in "753":
        a=a+dfs(s+c)

    return a

print(dfs("0"))

Submission status: Accepted

Solution code:
from itertools import product
N = int(input())
E = [3,5,7]
ans = 0

for i in range(3, len(str(N))+1) :
    L = product(E, repeat=i)
    for l in L :
        if (3 not in l) or (5 not in l) or (7 not in l) :
            continue
        number = int("".join(list(map(str,l))))
        if number <= N :
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
from itertools import product
N = int(input())

element = [3,5,7]
ans = 0
for i in range(3, len(str(N))+1) :
    L = product(element, repeat=i)
    for l in L :
        if ((3 not in l) or (5 not in l) or (7 not in l)) :
            continue
        number = int("".join(list(map(str,l))))
        if number <= N :
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
L=[3,5,7]
def num753(x):
    tmp=0
    for i in L:
        p=x*10+i
        if p<=N:
            if set([int(j) for j in str(p)])==set(L):
                tmp+=num753(p)+1
            else:
                tmp+=num753(p)
    return tmp
print(num753(0))

Submission status: Accepted

Solution code:
import itertools
N = int(input())
digits = [3, 5, 7]


def get_A_product(digits, N):
    A = []
    flag = False
    p = 3
    while True:
        for tup in itertools.product(digits, repeat=p):
            a = int("".join(list(map(str, tup))))
            if a > N:
                flag = True
                break
            A.append(a)
        if flag:
            break
        p += 1
    return A


count = 0
A = get_A_product(digits, N)
for a in A:
    if "3" in str(a) and "5" in str(a) and "7" in str(a):
        count += 1
print(count)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
p = 3
digits = [3, 5, 7]
A = []
flag = False
while True:
    for tup in itertools.product(digits, repeat=p):
        a = int("".join(list(map(str, tup))))
        if a > N:
            flag = True
            break
        A.append(a)
    if flag:
        break
    p += 1
count = 0
for a in A:
    if "3" in str(a) and "5" in str(a) and "7" in str(a):
        count += 1
print(count)

Submission status: Accepted

Solution code:
import itertools

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

def count_753(n):
    if n == 3:
        return (6, 18, 3)
    else:
        num_753 = count_753(n-1)[0] * 3 + count_753(n-1)[1]
        num_75 = count_753(n-1)[1] * 2 + count_753(n-1)[2] * 2
        return (num_753, num_75, 3)

if n <= 2:
    print(0)
else:
    count = 0
    for i in range(3, n+1):
        count += count_753(i)[0]
    #print('count :', count)

    for i in itertools.product(['7', '5', '3'], repeat=n):
        if len(set(i)) <= 2:
            continue
        s = 0
        for j,k in zip(range(n), reversed(range(n))):
            s += int(i[j]) * (10**k)
        if s > N:
            count -= 1
    
    print(count)

Submission status: Accepted

Solution code:
#解答より
N=int(input())

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

print (dfs("0"))

Submission status: Accepted

Solution code:
def is_753(N):
    x=[0,0,0,1]
    s=str(N)
    for i in s:
        if(i == '3'):
            x[0]+=1
        elif(i == '5'):
            x[1]+=1
        elif(i == '7'):
            x[2]+=1
        else:
            x[3]=0
    if(x[0]*x[1]*x[2]*x[3]!=0):
        return True
    else:
        return False

def dfs(li,x,lim):
    if(is_753(x) and x<=lim):
        li.append(x)
    if(x<=10**9):
        dfs(li,10*x+3,lim)
        dfs(li,10*x+5,lim)
        dfs(li,10*x+7,lim)



N = int(input())
li = []
dfs(li,0,N)
print(len(li))

Submission status: Accepted

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

def main():
    N = int(input())

    # 7 1
    # 5 1
    # 3 1
    # 75 2^k - 2
    # 73 2^k - 2
    # 53 2^k - 2
    # 753 3^k - 3(2^k - 2) - 3

    digits = len(str(N))
    r = 0
    for k in range(3, digits):
        r += (3 ** k - 3 * (2 ** k - 2) - 3)

    vt = [7, 5, 3]
    for k in range(1, digits):
        nvt = []
        for v in vt:
            nvt.append(v * 10 + 7)
            nvt.append(v * 10 + 5)
            nvt.append(v * 10 + 3)
        vt = nvt

    vt.sort()
    m = bisect.bisect_right(vt, N)
    for i in range(m):
        s = str(vt[i])
        if '7' in s and '5' in s and '3' in s:
            r += 1

    print(r)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

def check(s):
    counter = [False,False,False]
    for c in s:
        if c == "3":
            counter[0] = True
        elif c == "5":
            counter[1] = True
        elif c == "7":
            counter[2] = True
        if counter[0] and counter[1] and counter[2]:
            return True
    return False

def f(s,maxi):
    if int(s) > maxi:
        return 0
    if s == "0":
        s = ""
    if check(s):
        return f(s+"3",maxi) + f(s+"5",maxi) + f(s+"7",maxi) + 1
    
    return f(s+"3",maxi) + f(s+"5",maxi) + f(s+"7",maxi)
   
   
print(f("0",int(input())))

Submission status: Accepted

Solution code:
n = int(input())

count = 0
def dfs(x):
    global count
    if int(x) > n:
        return 0
    
    for i in ('753'):
        dfs(x+i)
    
    check =  True
    for j in ('753'):
        if x.find(j) == -1:
            check = False
    if check:
        count += 1
        
    return count
print(dfs('0'))

Submission status: Accepted

Solution code:
N=int(input())

L=[3,5,7]
def is_753(x, N):
  tmp=0
  for i in L:
    p=x*10+i
    if p<=N:
      if set([int(c) for c in str(p)])==set(L):
        tmp+=is_753(p, N)+1
      else:
        tmp+=is_753(p, N)
  return tmp

print(is_753(0, N))

Submission status: Accepted

Solution code:
N = int(input())
l = len(str(N))

def make753(num, l, list753):
    if l == 0:
        if '3' in num and '5' in num and '7' in num and int(num) <= N:
            list753.append(int(num))
    else:
        make753(num + '3', l-1, list753)
        make753(num + '5', l-1, list753)
        make753(num + '7', l-1, list753)
    return list753

L = []
for l in range(3, l+1):
    L += make753('', l, [])
print(len(L))

Submission status: Accepted

Solution code:
import numpy as np
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'))

Submission status: Accepted

Solution code:
def base4(n):
    r = []
    while 0 < n:
        r.append((0, 7, 5, 3)[n % 4])
        n //= 4
    return r

N = int(input())
count = 0
for i in range(1, 4**9):
    r = base4(i)
    if set(r) != {7,5,3}:
        continue
    x = int(''.join(map(str, r)))
    if x <= N:
        count += 1
print(count)

Submission status: Accepted

Solution code:
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'))

Submission status: Accepted

Solution code:
nl = ['3', '5', '7']


def r(n, s=''):
    c = 0
    if int(0 if s == '' else s) > int(n):
        return 0
    if all([x in s for x in nl]):
        c += 1
    for l in nl:
        c += r(n, s + l)
    return c


def main():
    n = input()
    print(r(n))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())


def f(s):

	if int(s) > N:
		return 0
		
	if all([s.count(i) for i in '357']):
		ret = 1
	else:
		ret = 0
		
	for i in '357':
		ret += f(s + i)
	return ret
	
	
print(f('0'))

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0
def dfs(n):
    global cnt
    if n>N:
        return 0
    s = str(n)
    if '3' in s and '5' in s and '7' in s:
        cnt += 1
    for j in [3,5,7]:
        dfs(n*10+j)
dfs(0)
print(cnt)

Submission status: Accepted

Solution code:
a = int(input())
b = ["3","5","7"]
c = []

for i1 in b:
    for i2 in b:
        for i3 in b:
            tmp = i1+i2+i3
            if "3" in tmp and "5" in tmp and "7" in tmp and int(tmp) <= a:
                c.append(tmp)
            for i4 in b:
                tmp = i1+i2+i3+i4
                if "3" in tmp and "5" in tmp and "7" in tmp and int(tmp) <= a:
                    c.append(tmp)
                for i5 in b:
                    tmp = i1+i2+i3+i4+i5
                    if "3" in tmp and "5" in tmp and "7" in tmp and int(tmp) <= a:
                        c.append(tmp)
                    for i6 in b:
                        tmp = i1+i2+i3+i4+i5+i6
                        if "3" in tmp and "5" in tmp and "7" in tmp and int(tmp) <= a:
                            c.append(tmp)
                        for i7 in b:
                            tmp = i1+i2+i3+i4+i5+i6+i7
                            if "3" in tmp and "5" in tmp and "7" in tmp and int(tmp) <= a:
                                c.append(tmp)
                            for i8 in b:
                                tmp = i1+i2+i3+i4+i5+i6+i7+i8
                                if "3" in tmp and "5" in tmp and "7" in tmp and int(tmp) <= a:
                                    c.append(tmp)
                                for i9 in b:
                                    tmp = i1+i2+i3+i4+i5+i6+i7+i8+i9
                                    if "3" in tmp and "5" in tmp and "7" in tmp and int(tmp) <= a:
                                        c.append(tmp)

    
print(len(c))

Submission status: Accepted

Solution code:
def make753(s):
    count = 0
    if int(s) > n:
        return 0
    if all(s.count(i) > 0 for i in ['7', '5', '3']):
        count += 1
    for i in ['7', '5', '3']:
        count += make753(s + i)
    return count

n = int(input())

print(make753('0'))

Submission status: Accepted

Solution code:
import itertools

n_s = input()
keta = len(n_s)
n = int(n_s)
count = 0

def list_753(n):
    l = list(itertools.product((7, 5, 3), repeat=n))
    ans = []
    for x in l:
        numstr = ''
        for i in range(n):
            numstr += str(x[i])
        ans.append(int(numstr))
    return sorted(ans)

def howmany_753(n):
    return ((3 ** n) - (3 * (2 ** n - 2)) - 3)

def judge_753(n):
    s = str(n)
    if s.count('7') * s.count('5') * s.count('3') != 0:
        return True
    else:
        return False

for i in range(3, keta):
    count += howmany_753(i)

numlist = list_753(keta)
for x in numlist:
    if x <= n:
        if judge_753(x) == True:
            count += 1
    else:
        break
print(count)

Submission status: Accepted

Solution code:
# 755
def func(s, n):
    a = list()
    if int(s) > n:
        return a
    if s.count('7') > 0 and s.count('5') > 0 and s.count('3') > 0:
        a.append(int(s))
    for char in '753':
        tmp = func(s+char, n)
        for k in tmp:
            a.append(k)
    return a


print(len(func('0', int(input()))))

Submission status: Accepted

Solution code:
import itertools


def solve():

    N = int(input())

    num = str(N)
    com = []
    com.append(('3', '5', '7'))
    com.append(('3', '5', '7'))
    res = 0
    dig = len(num)
    for x in range(3, dig+1):
        com.append(('3', '5', '7'))

        temp = list(itertools.product(*com))

        tempanswer = [i for i in temp if all(i.count(k) for k in '753')]
        answer = [int("".join(y)) for y in tempanswer if int("".join(y)) <= N]

        res = len(answer) + res
    print(res)


solve()

Submission status: Accepted

Solution code:
def listup(number, n):

    if number > 10 ** 9:
        return
    else:
        number = 10 * number + n
        if "7" in str(number):
            if "5" in str(number):
                if "3" in str(number):
                    list753.append(number)
        listup(number, 3)
        listup(number, 5)
        listup(number, 7)

list753 = []
ans = 0
N = int(input())
listup(0, 0)
for i in range(len(list753)):
    if N - list753[i] >= 0:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
def dfs(s):
    a = []
    if int(s) > N:
        return []

    if all (s.count(c) > 0 for c in '753'):
        a.append(int(s))

    for i in '753':
        p = dfs(s+i)
        for j in p:
            a.append(j)

    return a


N = int(input())

print(len(dfs('0')))

Submission status: Accepted

Solution code:
n = int(input())

zyunnsitigoL = [3, 5, 7]

def zyunnsitigo(zyunsiL):
    index=0
    newSitiL=[]
    while index < len(zyunsiL):
        newSitiL.append(int(str(zyunsiL[index])+"3"))
        newSitiL.append(int(str(zyunsiL[index])+"5"))
        newSitiL.append(int(str(zyunsiL[index])+"7"))
        index+=1
    return newSitiL

def sitigoCounter(n, zyunsiL):
    index =0
    count =0
    while index < len(zyunsiL):
        if zyunsiL[index]<n+1:
            newSL = list(map(int, list(str(zyunsiL[index]))))
            if 3 in newSL and 5 in newSL and 7 in newSL:
                if 0 in newSL or 1 in newSL or 2 in newSL or 4 in newSL or 6 in newSL or 8 in newSL or 9 in newSL:
                    pass
                else:
                    count+=1
        index+=1
    return count

def listMaker(n, zyunsiL):
    if n < 10:
        return zyunsiL
    else:
        newL = zyunnsitigo(zyunsiL)
        zyunsiL.extend(newL)
        if n > 100:
            newL=zyunnsitigo(newL)
            zyunsiL.extend(newL)
            if n > 1000:
                newL = zyunnsitigo(newL)
                zyunsiL.extend(newL)
                if n > 10000:
                    newL = zyunnsitigo(newL)
                    zyunsiL.extend(newL)
                    if n > 100000:
                        newL = zyunnsitigo(newL)
                        zyunsiL.extend(newL)
                        if n > 1000000:
                            newL = zyunnsitigo(newL)
                            zyunsiL.extend(newL)
                            if n > 10000000:
                                newL = zyunnsitigo(newL)
                                zyunsiL.extend(newL)
                                if n > 100000000:
                                    newL = zyunnsitigo(newL)
                                    zyunsiL.extend(newL)
        return zyunsiL

zyunsiL = listMaker(n, zyunnsitigoL)
ans = sitigoCounter(n, zyunsiL)
print(ans)

Submission status: Accepted

Solution code:
def gen_753(l,li=["7","5","3"]):
    if l == 1:
        return li
    new_li = []
    for cand in li:
        new_li.extend([cand + "7",cand + "5",cand + "3"])
    return gen_753(l-1,new_li)

num_str = input()
l = len(num_str)
num_ = int(num_str)
temp = []
for num in range(3,l+1):
    temp.extend(gen_753(num))
can_l = [int(num) for num in temp if len(set(list(num))) == 3]
count = sum([i <= num_ for i in can_l])
print(count)

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())

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

    for c in '753':
        ret += dfs(s+c)
    
    return ret

print(dfs('0'))

Submission status: Accepted

Solution code:
n = int(input())
def dfs(x):
    if int(x) > n:
        return 0
    
    if all(x.count(i) > 0 for i in "753"):
        ret = 1
    else:
        ret = 0
    
    for i in "753":
        ret += dfs(x+i)
        
    return ret
print(dfs("0"))

Submission status: Accepted

Solution code:
n=int(input())

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

print (sgs('0'))

Submission status: Accepted

Solution code:
def dfs(n):
    ret = 0
    if n > N:
        return ret
    s = str(n)
    if '3' in s and '5' in s and '7' in s:
        ret = 1
    for c in '753':
        ret += dfs(int(s+c))
    return ret

N = int(input())
print(dfs(0))

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0
def dfs(n):
    global cnt
    if n>N:
        return 0
    s = str(n)
    if '3' in s and '5' in s and '7' in s:
        cnt += 1
    dfs(int(s+'3'))
    dfs(int(s+'5'))
    dfs(int(s+'7'))

dfs(3)
dfs(5)
dfs(7)
print(cnt)

Submission status: Accepted

Solution code:
n = input()

m=int(n)
count = 0

def num753(start,n):
  global count
  if len(start) > len(n):
    return
  if int(start+"3") <= int(n) and "7" in start+"3" and "5" in start+"3" and "3" in start+"3":
    count +=1
  if int(start+"5") <= int(n) and "7" in start+"5" and "5" in start+"5" and "3" in start+"5":
    count +=1
  if int(start+"7") <= int(n) and "7" in start+"7" and "5" in start+"7" and "3" in start+"7":
    count +=1
    
  num753(start+"3",n)
  num753(start+"5",n)
  num753(start+"7",n)
  
  return count

print(num753("",n))

Submission status: Accepted

Solution code:
import  itertools
N = int(input())
N_len = len(str(N))

ans = 0
if N < 100:
    print(0)
for i in range(3,N_len+1):
    if i == N_len:
        l = list(itertools.product((3,5,7),repeat=N_len))
        ans += len(l)
        for s in l:
            a = int("".join(list(map(str,s))))
            if "3" not in str(a) or "5" not in str(a) or "7" not in str(a):
                ans -= 1
                continue
            if a > N:
                ans -= 1
        print(ans)

    else:
        ans += (3**i - 2**i*3 + 3)

Submission status: Accepted

Solution code:
N=int(input())
ans=0
def solve(st):
    if int(st)>N:
        return 0
    if all([st.count(c) for c in '357']):
        global ans
        ans = ans + 1
    solve(st+'3')
    solve(st+'5')
    solve(st+'7')
solve('0')
print(ans)

Submission status: Accepted

Solution code:
import sys, itertools

N = input()


def count(n3, n5, n7):
    r = [3] * n3 + [5] * n5 + [7] * n7
    s = map(lambda x: int("".join(map(str,x))), set(itertools.permutations(r)))
    return len([x for x in s if x <= N])


def comb(n):
    cnt = 0
    for a in range(1, 10):
        for b in range(1, 10):
            for c in range(1, 10):
                if a+b+c==n:
                    cnt+=count(a,b,c)
    return cnt

r = 0
for n in range(3, 10):
    r+=comb(n)
print(r)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
D = len(str(N))

ans = 0
for d in range(3,D+1):
    for ptn in itertools.product([3,5,7], repeat=d):
        if len(set(ptn)) < 3: continue
        n = int(''.join(map(str,ptn)))
        if n <= N:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools

n = int(input())

count = 0
for i in range(3, 11):
    for itr in itertools.product('357', repeat=i):
        if '3' not in itr or '5' not in itr or '7' not in itr:
            continue
        value = 0
        for j in range(i):
            value += int(itr[j])*10**j
        if value <= n:
            count += 1
print(count)

Submission status: Accepted

Solution code:
def dfs(s):
    res = 0
    if int(s) > N: return res
    if all(c in s for c in '753'): res += 1
    for v in '753': res += dfs(s + v)
    return res


N = int(input())
print(dfs('0'))

Submission status: Accepted

Solution code:
def check(var):
    return (0 <= var <= N) and all(c in str(var) for c in '753')


def dfs(x):
    res = 0
    if check(x): res += 1
    if x <= N:
        for v in 3, 5, 7:
            res += dfs(10 * x + v)
    return res


N = int(input())
print(dfs(0))

Submission status: Accepted

Solution code:
def check(var):
    in_range = var <= N
    all_num_in = all(c in str(var) for c in '753')
    return in_range and all_num_in


def dfs(x):
    res = 0
    if check(x):
        res += 1
    if x <= N:
        for v in 3, 5, 7:
            res += dfs(10 * x + v)
    return res


N = int(input())
print(dfs(0))

Submission status: Accepted

Solution code:
# x以降のグラフの753数
def dfs(x):
    if x > N: return 0
    res = 1 if all(c in str(x) for c in '753') else 0  # x自身が753数かどうか
    for v in 3, 5, 7:
        res += dfs(10 * x + v)
    return res


N = int(input())
print(dfs(0))

Submission status: Accepted

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

# AtCoder Beginner Contest 114：C - 755
import itertools


def main():
    N = int(raw_input().strip())

    cnt = 0
    seq = ('3', '5', '7')
    for i in range(3, len(str(N))+1):
        for word in itertools.product(seq, repeat=i):
            w = ''.join(word)
            if '3' in w and '5' in w and '7' in w:
                if int(w) <= N:
                    cnt += 1
    print cnt


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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'))

Submission status: Accepted

Solution code:
N = input()


def check(n, ln):
    if ln == 0:
        if int(N) >= int(n) and all(n.count(s) > 0 for s in '357'):
            return 1
        else:
            return 0
    cnt = 0
    for i in '357':
        cnt += check(n + i, ln - 1)
    return cnt


def main():
    cnt = 0
    for l in range(3, len(N) + 1):
        cnt += check('', l)
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = input()


def check(n, ln):
    if ln == 0:
        if int(N) >= int(n) and set(list(n)) == {'3', '5', '7'}:
            return [n]
        else:
            return []
    nums = []
    for i in ['3', '5', '7']:
        nums.extend(check(n + i, ln - 1))
    return nums


def main():
    cnt = 0
    for l in range(3, len(N) + 1):
        cnt += len(check('', l))
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

import itertools

def li_753():
    li = ["0", "7", "5", "3"]
    com = list(itertools.product(li, repeat=9))
    res = []
    for c in com:
        s = "".join(c)
        x = int(s)
        if "3" in s and "5" in s and "7" in s and "0" not in str(x):
            res.append(x)
    return res

def main():
    n = int(input())
    com = li_753()
    com = [x for x in com if x <= n]
    print(len(com))

main()