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

#print(n)

cnt=0

a=(3,5,7)
b=[]
for i9 in range(len(a)):
    for i8 in range(len(a)):
        for i7 in range(len(a)):
            for i6 in range(len(a)):
                for i5 in range(len(a)):
                    for i4 in range(len(a)):
                        for i3 in range(len(a)):
                            for i2 in range(len(a)):
                                for i in range(len(a)):
                                    x=str(a[i])+str(a[i2])+str(a[i3])+str(a[i4])+str(a[i5])+str(a[i6])+str(a[i7])+str(a[i8])+str(a[i9])
                                    if x.count('3') > 0 and x.count('5') > 0 and x.count('7') > 0:
                                        if int(x) <= n:
                                            cnt+=1
#                                        b.append(x)
#print(len(b9))

for i8 in range(len(a)):
    for i7 in range(len(a)):
        for i6 in range(len(a)):
            for i5 in range(len(a)):
                for i4 in range(len(a)):
                    for i3 in range(len(a)):
                        for i2 in range(len(a)):
                            for i in range(len(a)):
                                x=str(a[i])+str(a[i2])+str(a[i3])+str(a[i4])+str(a[i5])+str(a[i6])+str(a[i7])+str(a[i8])
                                if x.count('3') > 0 and x.count('5') > 0 and x.count('7') > 0:
                                    if int(x) <= n:
                                        cnt+=1
#                                        b.append(x)
#print(len(b8))

for i7 in range(len(a)):
    for i6 in range(len(a)):
        for i5 in range(len(a)):
            for i4 in range(len(a)):
                for i3 in range(len(a)):
                    for i2 in range(len(a)):
                        for i in range(len(a)):
                            x=str(a[i])+str(a[i2])+str(a[i3])+str(a[i4])+str(a[i5])+str(a[i6])+str(a[i7])
                            if x.count('3') > 0 and x.count('5') > 0 and x.count('7') > 0:
                                if int(x) <= n:
                                    cnt+=1
#                                        b.append(x)

#print(len(b7))

for i6 in range(len(a)):
    for i5 in range(len(a)):
        for i4 in range(len(a)):
            for i3 in range(len(a)):
                for i2 in range(len(a)):
                    for i in range(len(a)):
                        x=str(a[i])+str(a[i2])+str(a[i3])+str(a[i4])+str(a[i5])+str(a[i6])
                        if x.count('3') > 0 and x.count('5') > 0 and x.count('7') > 0:
                            if int(x) <= n:
                                cnt+=1
#                                        b.append(x)

#print(len(b6))


for i5 in range(len(a)):
    for i4 in range(len(a)):
        for i3 in range(len(a)):
            for i2 in range(len(a)):
                for i in range(len(a)):
                    x=str(a[i])+str(a[i2])+str(a[i3])+str(a[i4])+str(a[i5])
                    if x.count('3') > 0 and x.count('5') > 0 and x.count('7') > 0:
                        if int(x) <= n:
                            cnt+=1
#                                        b.append(x)

#print(len(b5))
      
for i4 in range(len(a)):
    for i3 in range(len(a)):
        for i2 in range(len(a)):
            for i in range(len(a)):
                x=str(a[i])+str(a[i2])+str(a[i3])+str(a[i4])
                if x.count('3') > 0 and x.count('5') > 0 and x.count('7') > 0:
                    if int(x) <= n:
                        cnt+=1
#                                        b.append(x)

#print(len(b4))

for i3 in range(len(a)):
    for i2 in range(len(a)):
        for i in range(len(a)):
            x=str(a[i])+str(a[i2])+str(a[i3])
            if x.count('3') > 0 and x.count('5') > 0 and x.count('7') > 0:
                if int(x) <= n:
                    cnt+=1
#                   b.append(x)
print(cnt)

Submission status: Accepted

Solution code:
#なるほど。再帰ねぇ。
iN = int(input())
iAns = 0
def fDFS(s):
    global iAns
    if iN < int(s) :
        return
    else:
        if "3" in s and "5" in s and "7" in s:
            iAns += 1
        fDFS(s + "3")
        fDFS(s + "5")
        fDFS(s + "7")
fDFS("3")
fDFS("5")
fDFS("7")
print(iAns)

Submission status: Accepted

Solution code:
n = int(input())

tmpl = [['']]
l = []
for i in range(1,10):
    #iは桁数
    tmp = []
    for x in tmpl[-1]:
        for s in '357':
            tmp.append(x+s)
    tmpl.append(tmp)
    l = l + tmp

def check(s):
    if all(s.count(x) for x in '357'):
        return True
    else:
        return False

ans = 0
for x in l:
    if int(x) <= n:
        if check(x):
            ans += 1
    else:
        break

print(ans)

Submission status: Accepted

Solution code:
def main():
    """
    1 <= N  <= 10^9

    七五三数とは以下の条件を満たす正の整数
    十進法で表記したとき、
    数字 7, 5, 3 がそれぞれ 1回以上現れ、これら以外の数字は現れない
    """
    N = int(input())

    # ans = f(N)
    ans = editorial(N)
    ans2 = editorial_movie(N)
    assert ans == ans2
    print(ans)


def editorial(N):
    def dfs(s):
        if int(s) > N:
            return 0

        ret = all(s.count(c) for c in "753")
        ret = int(ret)

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

        return ret

    ans = dfs("0")
    return ans


def editorial_movie(N):
    def dfs(x):
        if x > N:
            return 0

        s = str(x)
        ret = all(s.count(c) for c in "753")
        ret = int(ret)

        for c in [7,5,3]:
            ret += dfs(x * 10 + c)

        return ret

    ans = dfs(0)
    return ans

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import copy
import bisect as b
n=int(input())
l=[3,5,7]
s=[3,5,7]
ll=[]
for i in range(8):
    w=copy.deepcopy(l)
    for j in w:
        for k in s:
            l.append(int(str(j)+str(k)))
for i in range(len(l)):
    if len(set(str(l[i])))==3:
        ll.append(l[i])
ll=list(set(ll))
ll.sort()
print(b.bisect(ll,n))

Submission status: Accepted

Solution code:
from itertools import product

N = int(input())

count = 0
for i in range(2, len(str(N))):
  for p in set(product('753', repeat=i+1)):
    if int(''.join(p)) > N:
      continue
    if all(p.count(s) > 0 for s in '753'):
      count += 1

print(count)

Submission status: Accepted

Solution code:
#114-C
import bisect
n=int(input())
l=[]
ll=[]
s=[3,5,7]
for i in s:
    for j in s:
        for k in s:
            l.append(i*100+j*10+k)
for i in s:
    for j in s:
        for k in s:
            for m in s:
                l.append(i*1000+j*100+k*10+m)

for i in s:
    for j in s:
        for k in s:
            for m in s:
                for o in s:
                    l.append(i*10000+j*1000+k*100+m*10+o)
            
for i in s:
    for j in s:
        for k in s:
            for m in s:
                for o in s:
                    for p in s:
                        l.append(i*100000+j*10000+k*1000+m*100+o*10+p)
                    
for i in s:
    for j in s:
        for k in s:
            for m in s:
                for o in s:
                    for p in s:
                        for q in s:
                            l.append(i*1000000+j*100000+k*10000+m*1000+o*100+p*10+q)
                    

for i in s:
    for j in s:
        for k in s:
            for m in s:
                for o in s:
                    for p in s:
                        for q in s:
                            for r in s:
                                    l.append(i*10000000+j*1000000+k*100000+m*10000+o*1000+p*100+q*10+r)
                    
for i in s:
    for j in s:
        for k in s:
            for m in s:
                for o in s:
                    for p in s:
                        for q in s:
                            for r in s:
                                for t in s:
                                    l.append(i*100000000+j*10000000+k*1000000+m*100000+o*10000+p*1000+q*100+r*10+t)
for i in range(len(l)):
    if len(set(str(l[i])))==3:
        ll.append(l[i])
print(bisect.bisect(ll,n))

Submission status: Accepted

Solution code:
def dfs(N,s,a,b,c):
    if int(s)>N:
        return 0
    ret  = dfs(N,s+'3',True,b,c)
    ret += dfs(N,s+'5',a,True,c)
    ret += dfs(N,s+'7',a,b,True)
    return ret + (a and b and c)

print(dfs(int(input()),'0',False,False,False))

Submission status: Accepted

Solution code:
N = int(input())


def dfs(x, a, b, c):
    if x > N:
        return 0
    else:
        return all([a, b, c]) + dfs(x * 10 + 7, a, b, 1) + dfs(x * 10 + 5, a, 1, c) + dfs(x * 10 + 3, 1, b, c)


print(dfs(0, 0, 0, 0))

Submission status: Accepted

Solution code:
N = int(input())

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

print(dfs('0'))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N = int(input())
count = 0


def dfs(s):
    if int(s) > N: #終了条件
        return 
    
    list = []
    for c in '753': #753数か判定
        if s.count(c) > 0:
            list.append(True)
        else:
            list.append(False)
    if all(list):
        global count 
        count += 1;
    
        
    for c in '753':
        dfs(s + c)
    
    return

dfs('0')
print (count)

Submission status: Accepted

Solution code:
N = int(input())


def resol_a(x, a):
    if x < 10:
        return int(x >= a)
    d = 0
    while x > 10**(d+1):
        d += 1
    f = x // 10 ** d
    r = x % 10 ** d
    c = resol_a(r, a)
    b = resol_a(10 ** d - 1, a)
    bb = resol_a(10 ** (d - 1), a)
    if f > a:
        return b + 1
    elif f == a:
        return b + c - bb
    else:
        return b


def resol_ab(x, a, b):
    d = 0
    if x < 100:
        return (x >= 10 * b + a) + (x >= 10 * a + b)
    while x > 10 ** (d + 1):
        d += 1
    f = x // 10 ** d
    r = x % 10 ** d
    if f > a:
        return resol_ab((a+1)*10**d-1, a, b)
    elif f == a:
        return resol_ab(a * 10 ** d - 1, a, b) + max(resol_ab(r, a, b) - resol_ab(10 **
                                                                                  (d - 1), a, b), 0) + max(resol_a(r, b) - resol_a(10 ** (d - 1), b), 0)
    elif f > b:
        return resol_ab((b+1)*10 ** d - 1, a, b)
    elif f == b:
        return resol_ab(b * 10 ** d - 1, a, b) + max(resol_ab(r, a, b) - resol_ab(10 **
                                                                                  (d - 1), a, b), 0) + max(resol_a(r, a) - resol_a(10 ** (d - 1), a), 0)
    else:
        return resol_ab(10 ** d - 1, a, b)


def resol_abc(x, a, b, c):
    if x < 1000:
        A, B, C = str(a), str(b), str(c)
        return sum([x >= int(_) for _ in [A+B+C, A+C+B, B+A+C, B+C+A, C+A+B, C+B+A]])
    d = 0
    while x > 10 ** (d + 1):
        d += 1
    f = x // 10 ** d
    r = x % 10 ** d
    if f > a:
        return resol_abc((a+1)*10**d-1, a, b, c)
    elif f == a:
        return resol_abc(a*10**d-1, a, b, c)+max(resol_abc(r, a, b, c)-resol_abc(10**(d-1), a, b, c), 0)+max(resol_ab(r, b, c)-resol_ab(10**(d-1), b, c), 0)
    elif f > b:
        return resol_abc((b+1)*10**d-1, a, b, c)
    elif f == b:
        return resol_abc(b*10**d-1, a, b, c)+max(resol_abc(r, a, b, c)-resol_abc(10**(d-1), a, b, c), 0)+max(resol_ab(r, a, c)-resol_ab(10**(d-1), a, c), 0)
    elif f > c:
        return resol_abc((c+1)*10**d-1, a, b, c)
    elif f == c:
        return resol_abc(c*10**d-1, a, b, c)+max(resol_abc(r, a, b, c)-resol_abc(10**(d-1), a, b, c), 0)+max(resol_ab(r, a, b)-resol_ab(10**(d-1), a, b), 0)
    else:
        return resol_abc(10**d-1, a, b, c)


print(resol_abc(N, 7, 5, 3))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import itertools


def solve():
    n = int(input())
    cnt = 0
    for i in range(1, 11):
        for res in itertools.product(['3', '5', '7'], repeat=i):
            if int(''.join(res)) > n:
                print(cnt)
                return
            if '3' in res and '5' in res and '7' in res:
                cnt += 1


solve()

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 # s 自体が七五三数なら +1 
  for c in '753':
    ret += dfs(s + c)
  return ret
print(dfs('0'))

Submission status: Accepted

Solution code:
from sys import stdin
b = "357"
def valid(m):
 m = str(m)
 for i in b:
  if i not in m:
   return 0
 return 1
a = [3,5,7]
n = int(stdin.readline())
ans = 0
i = 0
while True:
 if i >= len(a):
  break
 cur = a[i]
 if cur > n:
  break
 if valid(cur):
  ans+=1
 a.append(cur*10 + 3); a.append(cur*10 + 5); a.append(cur*10 + 7)
 i+=1
print ans

Submission status: Accepted

Solution code:
import itertools as t;N,a,X=input(),0,[]
for i in range(len(N)+1):X+=list(t.product((3,5,7),repeat=i))
for i in X:
    s=''
    for j in i:s+=str(j)
    if len(set(i))>2and int(s)<=int(N):a+=1
print(a)

Submission status: Accepted

Solution code:
import itertools as t
N=int(input())
a,X=0,[]
for j in range(len(str(N))+1):X+=list(t.product((3,5,7),repeat=j))
for i in X:
    s=''
    for j in i:s+=str(j)
    if len(set(i))==3and int(s)<=N:a+=1
print(a)

Submission status: Accepted

Solution code:
import itertools
N=int(input())
k=len(str(N-1))
A=(3,5,7)
a=0
X=[]
for j in range(1,k+1):
    X+=list(itertools.product(A,repeat=j))
def nu(li):
    S=''
    for i in li:
        S+=str(i)
    return int(S)
for i in X:
    if (7 in i) and (5 in i) and (3 in i) and nu(i)<=N:
        a+=1
print(a)

Submission status: Accepted

Solution code:
import itertools

N = int(input())

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

Submission status: Accepted

Solution code:
import itertools, bisect
N = int(input())
d = len(str(N))
L =  []
for k in range(3,d+1):
    for a in itertools.product(["3","5","7"],repeat=k):
        if "3" in a and "5" in a and "7" in a:
            L.append(int("".join(a)))
L = sorted(L)
print(bisect.bisect_right(L,N))

Submission status: Accepted

Solution code:
N = int(input())
array = []
for i in range(10**9):
    res = ''
    digit = 0
    while i:
        res = '0357'[i % 4] + res
        i //= 4
    if '3' in res and '5' in res and '7' in res and '0' not in res:
        res = int(res)
        if res > 10 ** 9:
            break
        array += [res]
array += [10**9]
for i in range(len(array)):
    if array[i] > N:
        print(i)
        exit()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
def main():
	import numpy as np
	n = input()
	d = len(n)
	max = n

	r = 0		
	
	for i in range(3, d+1):#i keta wo tukuru
		for j in range(3**i):
			count = j
			buf = ""
			for k in range(1, i+1):#k keta
				if(count // 3**(i-k) == 2):
					buf = buf+"7"
					count -= 3**(i-k)*2
				elif(count // 3**(i-k) == 1):
					buf = buf+"5"
					count -= 3**(i-k)*1
				elif(count // 3**(i-k) == 0):
					buf = buf+"3"
			if("7" in buf and "5" in buf and "3" in buf and int(buf) <= int(max)):
				r += 1
				#print(buf)
	print(r)
		
main()

Submission status: Accepted

Solution code:
def isValid(num):
    s = str(num)
    cnt = {}
    for i in s:
        cnt[i] = 1
    return len(cnt) == 3
    

def dfs(num):
    if num > N:
        return 0
    a = dfs(num * 10 + 7)
    b = dfs(num * 10 + 5)
    c = dfs(num * 10 + 3)
    return a + b + c + isValid(num)

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

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=int(input())
r=filter
f=lambda c:sum([map(lambda z:z+y,f(c-1))for y in'357'],[]) if c!=0 else ['']
print(sum([len(r(lambda y:y==3,map(lambda x:len(set(sorted(x))),r(lambda z:int(z)<=N,f(e+1)))))for e in range(10)]))

Submission status: Accepted

Solution code:
N=int(input())
f=lambda c:sum([list(map(lambda z:z+y,f(c-1))) for y in '357'],[]) if c!=0 else ['']
print(sum([len(list(filter(lambda y:y==3,list(map(lambda x:len(set(sorted(x))),filter(lambda z:int(z)<=N,f(e+1))))))) for e in range(10)]))

Submission status: Accepted

Solution code:
n = int(input())
def dfs(s):
        if int(s) > n:
                return 0
        ret = 0
        if s.count('7')>0 and s.count('5')>0 and s.count('3')>0:
            ret = 1
        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 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+=dfs(s+c)
    return ret

print(dfs("0"))

Submission status: Accepted

Solution code:
s = input()
N = int(s)
ans = 0
arr = [3, 5, 7]
for n in range(3, len(s)+1):
    for i in range(3**n):
        m = 0
        j = n - 1
        count = [0]*3
        for j in range(n):
            dig = (i % 3**(j+1)) // 3**j
            m += 10**j * arr[dig]
            count[dig] += 1
        if (not 0 in count) and m <= N:
            ans += 1
print(ans)

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 = int(input())
count = 0
loop_N = 357
while(loop_N <= N) :
    count_3 = 0
    count_5 = 0
    count_7 = 0
    count_n = 0
    
    temp = str(loop_N)
    for j in range(0,len(temp)) :
        if temp[j] == "3" :
            count_3 += 1
        elif temp[j] == "5" :
            count_5 += 1
        elif temp[j] == "7" :
            count_7 += 1
        else :
            count_n += 1
            if temp[j] == "9" :
                temp = str(int(temp[:j+1]) + 1) + temp[j+1:]
            else :
                temp = temp[:j] + str(int(temp[j])+1) + temp[j+1:]
            loop_N = int(temp)
            break
    
    if count_3 > 0 and count_5 > 0 and count_7 > 0 and count_n < 1:
        count += 1
    if count_n < 1 :
        loop_N += 1
print(count)

Submission status: Accepted

Solution code:
def add(a):
	if int(a)>n:
		return 0
	else:
		ans = 0
		a = '' if int(a)==0 else a
		if a.find('3')>-1 and a.find('5')>-1 and a.find('7')>-1:
			ans+=1
		for i in [3,5,7]:
			ans+=add(a+str(i))
		return ans

n = int(input())
print(add('0'))

Submission status: Accepted

Solution code:
import itertools
N=int(input())
L=[]
S=[]
for i in range(3,10):
    for x in itertools.product('357',repeat=i):
        L.append(x)
for x in L:
    s=""
    for y in x:
        s+=y
    if "3" in s and "5" in s and "7" in s:
        S.append(int(s))
S.append(N)
S.sort()
if "3" in str(N) and "5" in str(N) and "7" in str(N):
    print(S.index(N)+1)
else:
    print(S.index(N))

Submission status: Accepted

Solution code:
import itertools
N=int(input())
L=[]
S=[]
for i in range(3,10):
    for x in itertools.product('357',repeat=i):
        L.append(x)
for x in L:
    s=""
    for y in x:
        s+=y
    if "3" in s and "5" in s and "7" in s:
        S.append(int(s))
S.append(N)
S=sorted(S)
if "3" in str(N) and "5" in str(N) and "7" in str(N):
    print(S.index(N)+1)
else:
    print(S.index(N))

Submission status: Accepted

Solution code:
import collections

n = int(input())

s = set()
que = collections.deque()
que.appendleft(0)
while que:
    v = que.pop()
    for c in '357':
        nv = v*10 + int(c)
        if nv <= n and nv not in s:
            s.add(str(nv))
            que.appendleft(nv)

ans = 0
for i in s:
    add = 1
    for c in '357':
        if c not in i:
            add = 0
    ans += add
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

def list753(n):
    if n == 1:
        return np.array([3,5,7],dtype=np.int)
    else:
        prev = list753(n-1)
        return np.concatenate((10*prev+3,10*prev+5,10*prev+7))

def all_list753(n):
    return np.concatenate(tuple([list753(i) for i in range(1,n+1)]))

Nstr = input()
N = int(Nstr)
Nlen = len(Nstr)

candidates = all_list753(Nlen)
ans = 0

for c in candidates:
    if c > N:
        continue
    cstr = str(c)
    if '3' in cstr and '5' in cstr and '7' in cstr:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
# coding: utf8

n = int(input())

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

print(dfs('0'))

Submission status: Accepted

Solution code:
ret = 0

n = int(input())

def dfs(i, f):
    if i > n:
        return
    if f == 7:
        global ret
        ret += 1
    dfs(i*10+3, f|1)

    dfs(i*10+5, f|2)
    dfs(i*10+7, f|4)

dfs(0, 0)
print(ret)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
from itertools import product
for i in range(3, 10):
    for t in product(["7", "5", "3"], repeat=i):
        d = {"7":True, "5":True, "3":True}
        for v in t:
            d[v] = False
        if True in d.values():
            continue

        n = int("".join(t))
        if n <= N:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
res = 0

def trans753(i):
    dict753=['0','3','5','7']
    num753=""
    while i>0:
        num753 = dict753[i%4] + num753
        i//=4
    return int(num753)

def verify753(i):
    if '0' in str(i):
        return False
    flag = [False for i in range(10)]
    while i>0:
        flag[i%10]=True
        i//=10
    return flag[7] and flag[5] and flag[3]

for i in range(1,4**10):
    num753 = trans753(i)
    if num753>N:
        break
    if verify753(num753):
        res+=1

print(res)

Submission status: Accepted

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

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 # s 自体が七五三数なら +1

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

print(dfs('0'))

Submission status: Accepted

Solution code:
import itertools

N = int(input())

li = []

for n in range(1, 10):
    for num in itertools.product("357", repeat=n):
        if(num.count("3") and num.count("5") and num.count("7")):
            li.append(int("".join(num)))

print(len([i for i in li if i <= N]))

Submission status: Accepted

Solution code:
import itertools

N = int(input())

li = []

for n in range(1, 10):
    for num in itertools.product("357", repeat=n):
        if(num.count("3") and num.count("5") and num.count("7")):
            li.append(int("".join(num)))

print(len([i for i in li if i <= N]))

Submission status: Accepted

Solution code:
N=int(input())
res = 0

def trans753(i):
    dict753=['0','3','5','7']
    num753=""
    while i>0:
        num753+=dict753[i%4]
        i//=4
    return int(num753[::-1])

def verify753(i):
    if '0' in str(i):
        return False
    flag = [False for i in range(10)]
    while i>0:
        flag[i%10]=True
        i//=10
    return flag[7] and flag[5] and flag[3]

for i in range(1,4**10):
    num753 = trans753(i)
    if num753>N:
        break
    if verify753(num753):
        res+=1

print(res)