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: Wrong Answer

Solution code:
S = input()

'''
357 375 537 573 735 753 
3357 3375 3537 3573 3735 3753 
5357 5375 5537 5573 5735 5753 
3357,3375,3537,

3けた　、4けた 5 ,6, 7, 8
6,18,54,162,486, 8
sum = [2 * 3,2 * 3 * 3,]
'''

N = len(S)
list375 =['3','5','7']
if N <  3:
    print(0)
    exit(0)

for i in range(N + 1):
    if i ==0:
        continue
    else:
        targetList = list375[:]
        for l in targetList:
            print(l)
            list375.append(l + '3')
            list375.append(l + '5')
            list375.append(l + '7')

result = [i for i in list(set(list375)) if int(i) < int(S) and i.count('3') !=0 and i.count('5') !=0 and i.count('7') !=0]
#print(result)
print(len(result))


'''
def judge753():
    if keta[0] < 3:
        return 0
    if keta[0] < 5:
        if keta[1] < 3:
            return 0
        if keta[1] < 5:
            if keta[2] < 5:
                return 0
            if keta[2] < 7:
                return 1
            return 2
        if keta[1] < 7:
            
        return sum[len(S)-1]
    if keta[0] < 7:
        if keta[1] < 3:
            return sum[len(S)-1] + sum[len(S)-2]
        if keta[1] < 5:
            if keta[2] < 5:
        
        return sum[len(S)-1]
        
print(min(absList))
'''

Submission status: Wrong Answer

Solution code:
S = input()

'''
357 375 537 573 735 753 
3357 3375 3537 3573 3735 3753 
5357 5375 5537 5573 5735 5753 
3357,3375,3537,

3けた　、4けた 5 ,6, 7, 8
6,18,54,162,486, 8
sum = [2 * 3,2 * 3 * 3,]
'''

N = len(S)
list375 =['3','5','7']
if N <  3:
    print(0)
    exit(0)

for i in range(N):
    if i ==0:
        continue
    else:
        targetList = list375[:]
        for l in targetList:
            list375.append(l + '3')
            list375.append(l + '5')
            list375.append(l + '7')

result = [i for i in list(set(list375)) if int(i) < int(S) and i.count('3') !=0 and i.count('5') !=0 and i.count('7') !=0]
#print(result)
print(len(result))


'''
def judge753():
    if keta[0] < 3:
        return 0
    if keta[0] < 5:
        if keta[1] < 3:
            return 0
        if keta[1] < 5:
            if keta[2] < 5:
                return 0
            if keta[2] < 7:
                return 1
            return 2
        if keta[1] < 7:
            
        return sum[len(S)-1]
    if keta[0] < 7:
        if keta[1] < 3:
            return sum[len(S)-1] + sum[len(S)-2]
        if keta[1] < 5:
            if keta[2] < 5:
        
        return sum[len(S)-1]
        
print(min(absList))
'''

Submission status: Wrong Answer

Solution code:
S = input()

'''
357 375 537 573 735 753 
3357 3375 3537 3573 3735 3753 
5357 5375 5537 5573 5735 5753 
3357,3375,3537,

3けた　、4けた 5 ,6, 7, 8
6,18,54,162,486, 8
sum = [2 * 3,2 * 3 * 3,]
'''

N = len(S)
list375 =['3','5','7']
if N <  3:
    print(0)
    exit(0)

for i in range(N):
    if i ==0:
        continue
    else:
        targetList = list375[:]
        for l in targetList:
            list375.append('3' + l)
            list375.append('5' + l)
            list375.append('7' + l)

result = [i for i in list(set(list375)) if int(i) < int(S) and i.count('3') !=0 and i.count('5') !=0 and i.count('7') !=0]
#print(result)
print(len(result))


'''
def judge753():
    if keta[0] < 3:
        return 0
    if keta[0] < 5:
        if keta[1] < 3:
            return 0
        if keta[1] < 5:
            if keta[2] < 5:
                return 0
            if keta[2] < 7:
                return 1
            return 2
        if keta[1] < 7:
            
        return sum[len(S)-1]
    if keta[0] < 7:
        if keta[1] < 3:
            return sum[len(S)-1] + sum[len(S)-2]
        if keta[1] < 5:
            if keta[2] < 5:
        
        return sum[len(S)-1]
        
print(min(absList))
'''

Submission status: Wrong Answer

Solution code:
S = input()

'''
357 375 537 573 735 753 
3357 3375 3537 3573 3735 3753 
5357 5375 5537 5573 5735 5753 
3357,3375,3537,

3けた　、4けた 5 ,6, 7, 8
6,18,54,162,486, 8
sum = [2 * 3,2 * 3 * 3,]
'''

N = len(S)
list375 =['3','5','7']

for i in range(N):
    if i ==0:
        continue
    else:
        targetList = list375[:]
        for l in targetList:
            list375.append('3' + l)
            list375.append('5' + l)
            list375.append('7' + l)

result = [i for i in list(set(list375)) if int(i) < int(S) and i.count('3') !=0 and i.count('5') !=0 and i.count('7') !=0]
#print(result)
print(len(result))


'''
def judge753():
    if keta[0] < 3:
        return 0
    if keta[0] < 5:
        if keta[1] < 3:
            return 0
        if keta[1] < 5:
            if keta[2] < 5:
                return 0
            if keta[2] < 7:
                return 1
            return 2
        if keta[1] < 7:
            
        return sum[len(S)-1]
    if keta[0] < 7:
        if keta[1] < 3:
            return sum[len(S)-1] + sum[len(S)-2]
        if keta[1] < 5:
            if keta[2] < 5:
        
        return sum[len(S)-1]
        
print(min(absList))
'''

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
s=['0','3','5','7']
must = ['3','5','7']
count = 0
for i_9 in range (4):
    for i_8 in range (4):
        for i_7 in range (4):
            for i_6 in range (4):
                for i_5 in range (4):
                    for i_4 in range (4):
                        for i_3 in range (4):
                            for i_2 in range (4):
                                for i_1 in range (4):
                                    num =s[i_9]+s[i_8]+s[i_7]+s[i_6]+s[i_5]+s[i_4]+s[i_3]+s[i_2]+s[i_1]
                                    num = int(''.join(list(map(str,num))))
                                    if (num<=N) & ('0' not in list(str(num))) & ('3' in list(str(num))) & ('5' in list(str(num))) & ('7' in list(str(num))) :
                                        count +=1
                                        
count

Submission status: Wrong Answer

Solution code:
N = int(input())
ret = 0
a = ['3','5','7']
i = 357
while i < N+1:
	t = list(set(str(i)))
	t.sort()
	if t == a:
		ret += 1
	i += 2
	if str(i)[-1] == '7':
		i += 4
print(ret)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())

def dfs(s):
    if int(s) > 0:
        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: Wrong Answer

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: Wrong Answer

Solution code:
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    else:
        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: Wrong Answer

Solution code:
N = int(input())
ret = 0
a = ['3','5','7']
for i in range(357, N+1):
    t = list(set(str(i))).sort()
    if t == a:
        ret += 1
print(ret)

Submission status: Wrong Answer

Solution code:
N = int(input())
ret = 0
a = ['3','5','7']
for i in range(357, N+1):
    t = list(set(str(i)))
    if t == a:
        ret += 1
print(ret)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())

def f(i,ans):
    if int(i) > N:
        return ans
    i = str(i)
    for a in A:
        ans += f(i+a,ans)-ans
    return ans

ans = 0
A = '357'
print(f(0,0))

Submission status: Wrong Answer

Solution code:
input = input()
il = len(input)
top = int(input[0])
if top >= 7:
  ans = 3*2*1*(3**(il-3))
elif top >= 5:
  ans = 2*2*1*(3**(il-3))
elif top >= 3:
  ans = 1*2*1*(3**(il-3))
else:
  ans = 3*2*1*(3**(il-4))
print(ans)

Submission status: Wrong Answer

Solution code:
n = input()

def dfs(now):
    if int(now) > int(n):
        return 1 if ("7" in now and "5" in now and "3" in now) else 0

    counter = 0
    for i in "753":
        counter += dfs(i + now)

    counter += 1 if ("7" in now and "5" in now and "3" in now) else 0
    return counter

print(dfs("0"))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from pprint import pprint


# Digit DP
def solve(N: int):
    s = str(N + 1)
    n = len(s)
    # dp[idx][smaller][started][3][5][7]
    dp = [[[[[[0 for _ in range(2)] for _ in range(2)] for _ in range(2)] for _ in range(2)] for _ in range(2)] for _ in range(n + 1)]
    dp[0][0][0][0][0][0] = 1
    for i in range(0, n):
        for smaller in range(2):
            for started in range(2):
                for i1 in range(2):
                    for i2 in range(2):
                        for i3 in range(2):
                            for nex in [0, 3, 5, 7]:
                                if not smaller and nex > int(s[i]):
                                    #print(i, nex)
                                    continue
                                if started and nex == 0:
                                    continue
                                #print(i, smaller, started, i1, i2, i3)
                                #print(dp[0][0][0][0][0][0])
                                #if not (smaller | nex < int(s[i])):
                                #    print(' --- ')
                                #    print(i, smaller, started, i1, i2, i3, nex, int(s[i]), nex < int(s[i]))
                                #    print(smaller, nex < int(s[i]))
                                #    print(smaller or nex < int(s[i]))
                                #    print(' --- ')

                                #dp[i + 1][smaller or nex < int(s[i])][started or nex > 0][i1 or nex == 3][i2 or nex == 5][i3 or nex == 7] += \
                                dp[i + 1][smaller | nex < int(s[i])][started | nex > 0][i1 | nex == 3][i2 | nex == 5][i3 | nex == 7] += \
                                    dp[i][smaller][started][i1][i2][i3]
        #pprint(dp[i])
        #print()
    ret = dp[n][1][1][1][1][1]
    #pprint(dp[n])
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())

def dfs(s): # 文字列 s で始まる七五三数の個数
    print(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')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく

Submission status: Wrong Answer

Solution code:
n = int(input())
def counter(num1, num2):
	if num2 == "0":
		num21 = "3"
		num22 = "5"
		num23 = "7"
		return counter(num1, num21) + counter(num1, num22) + counter(num1, num23)
	elif int(num2) > num1:
		return 0
	else:
		result = 0
		num21 = "3" + num2
		num22 = "5" + num2
		num23 = "7" + num2
		if "3" in num21 and "5" in num21 and "7" in num21 and int(num21) <= num1:
			result += 1
			print(num21)
		if "3" in num22 and "5" in num22 and "7" in num22 and int(num22) <= num1:
			result += 1
			print(num22)
		if "3" in num23 and "5" in num23 and "7" in num23 and int(num23) <= num1:
			result += 1
			print(num23)
		return counter(num1, num21) + counter(num1, num22) + counter(num1, num23) + result

print(counter(n, "0"))

Submission status: Wrong Answer

Solution code:
n=int(input())
import bisect
import itertools
l=len(str(n))
ans=[]
num=[]
x=['3', '5', '7']
for k in range(3,l+1):
    m=list(itertools.product(x, repeat=k))
    num.extend(m)
for i in range(len(num)):
    y=num[i]
    if '3' in y and '5' in y and '7' in y:
        number=''
        for j in range(len(y)):
            number+=y[j]
        ans.append(int(number))
ans.sort()
print(bisect.bisect_left(ans, n))

Submission status: Wrong Answer

Solution code:
import math

N = input()
m = len(N)

ans = 0
if m <= 2:
    pass
elif m == 3:
    f = int(N[0])
    if f < 3:
        pass
    elif 3 <= f < 5:
        ans = 2
    elif 5 <= f < 7:
        ans = 4
    else:
        ans = 6
else:
    m -= 1
    for i in range(3, m+1):
        for j in range(i-2):
            for k in range(i-2-j):
                a, b, c = j, k, i-3-j-k
                ans += math.factorial(i)/math.factorial(a+1)/math.factorial(b+1)/math.factorial(c+1)
    f = int(N[0])
    if f < 3:
        pass
    elif 3 < f < 5:
        for j in range(m-1):
            for k in range(m-1-j):
                a, b, c = j, k, m-2-j-k
                ans += math.factorial(m)/math.factorial(a)/math.factorial(b+1)/math.factorial(c+1)
    elif 5 < f < 7:
        tmp = 0
        for j in range(m-1):
            for k in range(m-1-j):
                a, b, c = j, k, m-2-j-k
                tmp += math.factorial(m)/math.factorial(a)/math.factorial(b+1)/math.factorial(c+1)
        ans += tmp*2
    elif 7 < f:
        for j in range(m-1):
            for k in range(m-1-j):
                a, b, c = j, k, m-2-j-k
                ans += math.factorial(m+1)/math.factorial(a+1)/math.factorial(b+1)/math.factorial(c+1)
    elif f == 3 or f == 5 or f == 7:
        s1, s2 = 0, 0
        for j in range(m-2):
            for k in range(m-2-j):
                a, b, c = j, k, m-3-j-k
                s1 += math.factorial(m-1)/math.factorial(a)/math.factorial(b+1)/math.factorial(c+1)
        for j in range(m-1):
            for k in range(m-1-j):
                a, b, c = j, k, m-2-j-k
                s2 += math.factorial(m-1)/math.factorial(a)/math.factorial(b)/math.factorial(c+1)
        g = int(N[1])
        if f == 3:
            if g < 3:
                pass
            elif 3 <= g < 5:
                ans += s1
            elif 5 <= g < 7:
                ans += s1 + s2
            else:
                ans += s1 + s2*2
        elif f == 5:
            if g < 3:
                ans += s1 + s2*2
            elif 3 <= g < 5:
                ans += s1 + s2*3
            elif 5 <= g < 7:
                ans += s1*2 + s2*3
            else:
                ans += s1*2 + s2*4
        else:
            if g < 3:
                ans += s1*2 + s2*4
            elif 3 <= g < 5:
                ans += s1*2 + s2*5
            elif 5 <= g < 7:
                ans += s1*2 + s2*6
            else:
                ans += s1*3 + s2*6

print(int(ans))

Submission status: Wrong Answer

Solution code:
import itertools
n=int(input())

keta=len(str(n))
hako=[]
for i in range(3,keta+1):
    for c in list(itertools.product(["7","5","3"],repeat=i)):
        if len(set(c))==3:
            a=int("".join(c))
            hako.append(a)
if n in hako:
    hako.sort()
    k=hako.index(n)
    b=hako[:k]
    print(len(b)) 
else:
    hako.append(n)
    hako.sort()
    k=hako.index(n)
    b=hako[:k]
    print(int(len(b))+1)

Submission status: Wrong Answer

Solution code:
import itertools
n=int(input())

keta=len(str(n))
hako=[]
for i in range(3,keta+1):
    for c in list(itertools.product(["7","5","3"],repeat=i)):
        if len(set(c))==3:
            a=int("".join(c))
            hako.append(a)
if n in hako:
    hako.sort()
    k=hako.index(n)
    b=hako[:k]
    print(len(b))
else:
    hako.append(n)
    hako.sort()
    k=hako.index(n)
    b=hako[:k]
    print(len(b))

Submission status: Wrong Answer

Solution code:
import itertools
n=int(input())

keta=len(str(n))
hako=[]
for i in range(3,keta+1):
    for c in list(itertools.product(["7","5","3"],repeat=i)):
        if len(set(c))==3:
            a=int("".join(c))
            hako.append(a)
hako.append(n)
hako.sort()
k=hako.index(n)
b=hako[:k]
print(len(b))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
for i in range(N):
    I = str(i)
    if I.count("3") != 0 and I.count("5") != 0 and I.count("7") != 0:
        if len(I.replace("3","").replace("5","").replace("7","")) == 0:
            A.append(i)
print(len(A))

Submission status: Wrong Answer

Solution code:
N = int(input())

list_cnt = []

for i in range(0, N):
    text_num = str(i)
    if((text_num.find("0")==-1) & (text_num.find("1")==-1) & (text_num.find("2")==-1) \
        & (text_num.find("3")>-1) & (text_num.find("4")==-1) & (text_num.find("5")>-1) \
        & (text_num.find("6")==-1) & (text_num.find("7")>-1) & (text_num.find("8")==-1) \
        & (text_num.find("9")==-1)):
        list_cnt.append(text_num)

print(len(list_cnt))

Submission status: Wrong Answer

Solution code:
from itertools import product
N = input()
length = len(N)
T = [''.join(t) for t in product(('3','5','7'),repeat = 3)]

def f(N,s):
    if len(s) == length:
        if int(s) < int(N) and '3' in s and '5' in s and '7' in s:
            return 1
        else:
            return 0
    else:
        if '3' in s and '5' in s and '7' in s:
            a = 1
        else:
            a = 0
        a += sum(f(N,s+c) for c in('3','5','7'))
        return a
if int(N)<357:
    print(0)
else:
    print(sum(f(N, t) for t in T))

Submission status: Wrong Answer

Solution code:
N=int(input())

ans = 0
def dfs(s, sum):
  global ans
  sum = sum + s

  if int(sum) >= N:
    return False
  
  if sum.count("3") >= 1 and sum.count("5") >= 1 and sum.count("7") >= 1:
    ans += 1
  
  if dfs("3", sum):
    return True
  
  if dfs("5", sum):
    return True
  
  if dfs("7", sum):
    return True
  
  
dfs("0" ,'')
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[0,3,5,7]
p=[]
flag=True
flag2=True
for c1 in x:
  for c2 in x:
    for c3 in x:
      for c4 in x:
        for c5 in x:
          for c6 in x:
            for c7 in x:
              for c8 in x:
                for c9 in x:
                  line=[c1,c2,c3,c4,c5,c6,c7,c8,c9]
                  sum_=0
                  if line.count(7)>0 and line.count(3)>0 and line.count(5)>0:
                    for i in range(9):
                      if flag==False and line[i] in [3,5,7]:
                        flag2=False
                        break
                      if line[i]==0:
                        flag=False
                      sum_+=line[i]*10**i
                    if flag2==False:
                      flag=True
                      flag2=True
                      continue
                    p.append(sum_)
                    flag=True
p.sort()
for i in range(len(p)):
  if p[i]>n:
    print(i)
    exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[0,3,5,7]
p=[]
for c1 in x:
  for c2 in x:
    for c3 in x:
      for c4 in x:
        for c5 in x:
          for c6 in x:
            for c7 in x:
              for c8 in x:
                for c9 in x:
                  line=[c1,c2,c3,c4,c5,c6,c7,c8,c9]
                  sum_=0
                  if line.count(7)>0 and line.count(3)>0 and line.count(5)>0:
                    for i in range(9):
                      sum_+=line[i]*10**i
                    p.append(sum_)
p.sort()
for i in range(len(p)):
  if p[i]>n:
    print(i)
    exit()

Submission status: Wrong Answer

Solution code:
#coding: utf-8
from collections import Counter
N = int(input())
l = ["0", "3", "5", "7"]
ans = ["0" for _ in range(9)]
cnt = 0
for a in l:
    ans[0] = a
    for b in l:
        ans[1] = b
        for c in l:
            ans[2] = c
            for d in l:
                ans[3] = d
                for e in l:
                    ans[4] = e
                    for f in l:
                        ans[5] = f
                        for g in l:
                            ans[6] = g
                            for h in l:
                                ans[7] = h
                                for i in l:
                                    ans[8] = i
                                    ans_c = Counter(ans)
                                    ans_i = int("".join(ans))
                                    #if ans_i <= N and sum([l[j] in str(ans_i) for j in range(len(l))]) == 3 and len(ans_c.values()) == 3:
                                    if ans_i <= N and "0" not in str(ans_i) and len(ans_c.keys()) == 4 and len(str(ans_i)) >= 3:
                                        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
def Base_n_to_10(X,n):
    out = 0
    for i in range(1,len(str(X))+1):
        out += int(X[-i])*(n**(i-1))
    return out
def Base_10_to_n(X,n):
    if X//n:
        return Base_10_to_n(X//n,n)+str(X%n)
    return str(X%n)
s = input()
tr = str.maketrans("0123456789","0001122333")
count = 0
for i in range(1,Base_n_to_10(s.translate(tr),4)+1):
  xx = Base_10_to_n(i,4)
  if "1" in xx and "2" in xx and "3" in xx and "0" not in xx:
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
0

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())

ans = 0

for i in range(n):
    if str(i) in "7" and str(i) in "5" and str(i) in "3":
        if not str(i) in ["1", "2", "4", "6", "8", "9"]:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
N = int(input())
l = len(str(N))
ans = 0
if l < 3:
	pass
else:
	S = []
	for k in range(3,l+1):
		S += list(itertools.product(['3', '5', '7'], repeat=k))
	print(S)
	for i in range(len(S)):
		num = ''
		for t in range(len(S[i])):
			num = num + S[i][t]
		# print(num)
		if '3' in num:
			if '5' in num:
				if '7' in num:
					if int(num) <= N:
						print(num)
						ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
n = len(str(N))
# 深さ優先で生成
# 3,5,7が含まれること、Nより小さいことをチェックしてカウント
def dfs(cur, st, n):
    if cur==n:
        if int(st)<N and ('3' in st and'5' in st and'7'  in st):
            # print((('3'and'5'and'7') in st), st)
            return +1
        else:
            return +0
    else:
        ret1 = dfs(cur+1, st+'3', n)
        ret2 = dfs(cur+1, st+'5', n)
        ret3 = dfs(cur+1, st+'7', n)
        return ret1 + ret2 + ret3

s = 0
for i in range(3, n+1):
    s += dfs(0, '', i)
print(s)

Submission status: Wrong Answer

Solution code:
import bisect

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

k753_num = []
def get_k753_num(k, s):
  if k == 0:
    if "7" in s and "5" in s and "3" in s:
      k753_num.append(int(s))
      return True
    else:
      return False
  pata = get_k753_num(k-1, "7" + s)
  patb = get_k753_num(k-1, "5" + s)
  patc = get_k753_num(k-1, "3" + s)
  
def count_k753_num(k):
  if k<3:
    return 0
  else:
    return 3**k - (2**k * 3) + 3

# count up k-1 753 num
count = 0
for i in range(k):
  count += count_k753_num(i)

# add k 753 num
get_k753_num(k, "")
k753_num.sort()
count += bisect.bisect_left(k753_num, n)

print(count)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
ls = [x+1 for x in range(N)]
candidates = [str(x) for x in ls if "7" in str(x) and "5" in str(x) and "3" in str(x)]
count = 0
for _ in range (len(candidates)):
    candlist = list(candidates)
    ls2 = [x for x in candlist if x != "7" and x != "5"and x != "3"]
    if ls2 is False:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
count = 0
for i in range (N):
    num = str(i+1)
    ls = list(num)
    ls2 = [x for x in ls if int(x) != 7 and int(x) != 5 and int(x) !=3]
    if ls2 is False and "7" in num and "5" in num and "3" in num:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
count = 0
for i in range (N):
    num = str(i+1)
    ls = list(num)
    ls2 = [x for x in ls if int(x) != 7 and int(x) != 5 and int(x) !=3]
    if ls2 is False:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
count = 0
for i in range(N+1):
	three = '3' in str(i)
	five = '5' in str(i)
	seven = '7' in str(i)
	if three == True and five == True and seven == True:
		count+= 1
print(count)

Submission status: Wrong Answer

Solution code:
import itertools
n=input()
c=[0,0,6,36,150,540,1806,5796,18150]
b=len(list(a for a in itertools.product(["3","5","7"],repeat=len(n))if len(set(a))==3 and int("".join(a))<int(n)))
print(sum(c[:len(n)-1])+b)

Submission status: Wrong Answer

Solution code:
N=int(input())
 
def dfs(i,count):
    if i!="":
        if int(i)>=N:
            return count
    if "3" in i and "5" in i and "7" in i:
        count+=1
    count=dfs("3"+i,count)
    count=dfs("5"+i,count)
    count=dfs("7"+i,count)
    return count
  
print(dfs("",0))

Submission status: Wrong Answer

Solution code:
N=int(input())

def dfs(i,count):
    if i!="":
        if int(i)>=N:
            return count
    if "3" in i and "5" in i and "7" in i:
        count+=1
    count=dfs("3"+i,count)
    count=dfs("5"+i,count)
    count=dfs("7"+i,count)
    return count
  
dfs("",0)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 0
k = 0
def dfs(k):
  if k > n :
    return ans
  else:
    ans += 1
  ret0 = dfs(k*10 + 3)
  ret1 = dfs(k*10 + 5)
  ret2 = dfs(k*10 + 7)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 0
k = 0
def dfs(n):
  if k > n :
    return ans
  else:
    ans += 1
  ret0 = k*10 + 3
  ret1 = k*10 + 5
  ret2 = k*10 + 7
print(ans)

Submission status: Wrong Answer

Solution code:
def rec(N,k=0,tight=True,_7=False, _5=False, _3=False):
    if k==len(N):
        if _7==True and _5==True and _3==True:
            return 1
        else:
            return 0  
    x=N[k]
    r=int(x)  
    if r<3 and tight:
        return 0
    #res = dp[k][0]+dp[k][1]
    res=0
    for i in [3,5,7]:
        next_tight = tight and i==r
        next_3 = _3
        next_5 = _5
        next_7 = _7
        if tight:
            if i>r:
                return res
        if i==3:
            next_3=True
        elif i==5:
            next_5=True
        elif i==7:
            next_7=True
        temp_rec = rec(N,k+1,next_tight,next_7,next_5,next_3)
        res+=temp_rec
    return res
N=input()
print(rec(N))

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
count = 0

for i in range(1, n + 1):
	c = collections.Counter(list(str(i)))
	if len(c.keys()) == 3:
		print(c)
		if (c['3'] != 0) and (c['5'] != 0) and (c['7'] != 0):
			count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
count = 0

for i in range(n):
	c = collections.Counter(list(str(i)))
	if len(c.keys()) == 3:
		if (c['3'] != 0) and (c['5'] != 0) and (c['7'] != 0):
			count += 1
print(count)

Submission status: Wrong Answer

Solution code:
print(len([i for i in range(1,int(input()),2) if set(str(i))=={'3','5','7'}]))

Submission status: Wrong Answer

Solution code:
from itertools import product

N = int(input())

cnt = 0
for k in range(3, 10+1):
    for x in product("753", repeat=k):
        if set(x) < set("753"):
            continue
        v = int("".join(x))
        if v < N:
            cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
count = 0
def detect_755(integer):
    target = str(integer)
    if "7" in target and "5" in target and "3" in target:
        pass
    else:
        return False
    if set(target) == {"3","5","7"}:
        return True
    else:
        return False

i = 11
while i < N:
    if str(i)[0] in "357":
        if detect_755(i):
            count += 1
    else:
        i += 10**(len(str(i)) - 1)
        continue
    i += 2
print(count)

Submission status: Wrong Answer

Solution code:
import itertools
from sys import stdin
N=int(stdin.readline().rstrip())
ans=0
for i in range(3,6):
    for j in list(itertools.product("753",repeat=i)):
        if int("".join(j)) <= N and len(set("".join(j)))==3:
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

m = 0
c = [0, 3, 5, 7]
count = 0

def p753(m):
    i = 0
    s = 0 if m > 0 else c[0]
    while m > 0:
        s += 10**i * c[m % 4]
        i += 1
        m = m // 4
    return s

p = p753(m)

while p < n:
    mt = m
    f = [False, False, False, False]
    
    while mt > 0:
        f[mt % 4] = True
        if mt % 4 == 0:
            break
        mt = mt // 4
    if (not f[0]) and f[1] and f[2] and f[3]:
        count += 1
    m += 1
    p = p753(m)

print(count)

Submission status: Wrong Answer

Solution code:
list = []

def dfs(length,num):
    global list
    if len(num) == length:
        list.append(num)
        return

    for i in ['3','5','7']:
        newnum = num + i
        dfs(length,newnum)

    return


N = input()
ans = 0

for i in range(1,len(N) + 1):
    dfs(i,'')

for i in list:
    if ('3' in i) and ('5' in i) and ('7' in i):
        if int(N) > int(i):
            ans += 1

print(ans)

Submission status: Wrong Answer

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

def judge(i):
    flag3 = False
    flag5 = False
    flag7 = False
    for j in range(0,len(i)):
        if i[j] == "3":
            flag3  = True
        elif i[j] == "5":
            flag5 = True
        elif i[j] == "7":
            flag7 = True
        else:
            return False
    if flag3 and flag5 and flag7:
        return True
    else:
        return False

for i in range(0,N):
    i = str(i)
    if judge(i):
        count = count+1

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
cnt = 0

def out(s):
    
    i_s = int(s)
    if i_s < n:
        #7, 5, 3が1以上出現する
        if all([True if str(i_s).count(s) > 0 else False for s in '753']):
            global cnt
            #print(i_s)
            cnt +=1 
            #7, 5, 3を引っ付ける
            
        [out(str(i_s) + s) for s in '753']

out('0')
print(cnt)

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
ori = [3, 5, 7]
num = []
num.append(0)
ans = []
i = 1
while i < 10:
    num.append(list(itertools.product(ori, repeat=i)))
    for k in range(len(num[i])):
        if (3 in num[i][k]) and (5 in num[i][k]) and (7 in num[i][k]):
            ans.append(int(''.join([str(x) for x in num[i][k]])))
    i += 1
count = 0
for f in ans:
    if n > f:
        count += 1
print(count)