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:
# -*- coding: utf-8 -*-
import copy 

def mul(nums, digit):
    r = []
    for num in nums:
        for v in ["3", "5", "7"]:
            r.append(v+num)            
            for i in range(1,len(num)):
                n = list(num)
                n.insert(i, v)
                r.append("".join(copy.deepcopy(n)))
            r.append(num+v)
    return r


nums = ["357", "375", "537", "573", "735", "753"]
s = input()

if len(s) < 3:
    print(0)
elif len(s) == 3:
    count = 0
    for v in nums:
        if int(s) > int(v):
            count += 1
    print(count)
else:
    count = 0
    for i in range(len(s) - 3):
        nums = list(set(mul(nums, i+4)))
    s = int(s)
    print(sum(int(num)<s for num in set(nums)))

Submission status: Wrong Answer

Solution code:
x=input()
n=int(x)
m=len(x)
ans=0
for i in range(1,m+1):
    ans +=3**i-(3*2**i)+3
for i in range(n,8*10**(m-1)):
    j=str(i)
    k=set(j)
    if str(3) in j and str(5) in j and str(7) in j:
        if len(k)==3:
            ans -=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=0
if n<10**7:
  if n%2==0:
    for i in range(1,n-1,2):
      sum3=0
      sum5=0
      sum7=0
      x=str(i)
      l=len(x)
      for j in range(l):
        if x[j]=='3':
          sum3 += 1
        elif x[j]=='5':
          sum5 += 1
        elif x[j]=='7':
          sum7 += 1
        if (sum3 + sum5 + sum7 == l) and (sum3>0) and(sum5>0) and (sum7>0):
          ans+=1
  else:
    for i in range(1,n,2):
      sum3=0
      sum5=0
      sum7=0
      x=str(i)
      l=len(x)
      for j in range(l):
        if x[j]=='3':
          sum3 += 1
        elif x[j]=='5':
          sum5 += 1
        elif x[j]=='7':
          sum7 += 1
        if (sum3+sum5+sum7==l) and (sum3>0) and(sum5>0) and (sum7>0):
          ans+=1
  print(ans)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

ans = 0

if ord > 0:
  for i in range(ord):
    ans = ans + 3**i - 3 * (2**i) + 3

for j in range(10**ord, n):
  strj = str(j)
  test = [0]*3
  
  for k in strj:
    if k != 3 and k!=5 and k!=7:
      break
    elif k ==3:
      test[0] =1
    elif k == 5:
      test[1]=1
    elif k == 7:
      test[1] = 1
  if test == [1,1,1]:
    ans = ans + 1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
N_list = []
N_753 = 0

for n in range(N):
    if n % 10 == 3 or 7 or 5:
        N_list.append(n)

for m in N_list:
    if all(x in str(m) for x in (str(7), str(5), str(3))) and not any(x in str(m) for x in (str(0), str(1), str(2), str(4), str(6), str(8), str(9))):
        N_753 +=1

print(N_753)

Submission status: Wrong Answer

Solution code:
# Input
x = int(input())

# Search 753 Num
cnt_753 = 0
for idx in range(0, x):

    exist3 = False
    exist5 = False
    exist7 = False
    skip_flg = True
    sav_idx = idx

    while skip_flg == True and sav_idx > 0:
        check_val = sav_idx % 10
        sav_idx = int(sav_idx / 10)
        if check_val == 3:
            exist3 = True
        elif check_val == 5:
            exist5 = True
        elif check_val == 7:
            exist7 = True
        else:
            skip_flg = False

    if exist3 and exist5 and exist7 and skip_flg:
        cnt_753 += 1

# Output
print (cnt_753)

Submission status: Wrong Answer

Solution code:

inn = int(input())

result = 0

if inn < 357:
    print(0)

elif inn < 99999999:
    for i in range(357, inn, 2):

        str_i = str(i)

        num_3 = 0
        num_5 = 0
        num_7 = 0

        # check_357 = [i in ['3','5','7'] for i in str(i)]
        # if sum(check_357) == len(str_i):

        # if '3' in str_i and '5' in str_i and '7' in str_i:
            # if re.sub(r'3|5|7', '', str_i) == '':

        for j in str_i:
            if num_3 == 0 and j == '3':
                num_3 = 1

            elif num_5 == 0 and j == '5':
                num_5 = 1

            elif num_7 == 0 and j == '7':
                num_7 = 1

            elif j in ['0', '1', '2', '4', '6', '8', '9']:
                num_3 = 0
                break

            # if '0' not in str_i and '1' not in str_i and '2' not in str_i and '4' not in str_i and '6' not in str_i and '8' not in str_i and '9' not in str_i:

        if num_3 == 1 and num_5 == 1 and num_7 == 1:
                result += 1

    print(result)

else:
    result = 8334
    if inn >= 333333357 and inn < 533333337:
        for i in range(333333357, inn if inn <= 377777776 else 377777776, 2):

            str_i = str(i)

            if '3' in str_i and '5' in str_i and '7' in str_i:
                if '0' not in str_i and '1' not in str_i and '2' not in str_i and '4' not in str_i and '6' not in str_i and '8' not in str_i and '9' not in str_i:

                    result += 1

    elif inn >= 533333337 and inn < 733333335:
        result = 14384
        for i in range(533333337, inn if inn <= 577777774 else 577777774, 2):

            str_i = str(i)

            if '3' in str_i and '5' in str_i and '7' in str_i:
                if '0' not in str_i and '1' not in str_i and '2' not in str_i and '4' not in str_i and '6' not in str_i and '8' not in str_i and '9' not in str_i:

                    result += 1

    elif inn >= 733333335 and inn <= 777777754:
        result = 20434
        for i in range(733333335, inn if inn <= 777777754 else 777777754, 2):

            str_i = str(i)

            if '3' in str_i and '5' in str_i and '7' in str_i:
                if '0' not in str_i and '1' not in str_i and '2' not in str_i and '4' not in str_i and '6' not in str_i and '8' not in str_i and '9' not in str_i:

                    result += 1

    elif inn > 777777754:
        result = 26484

    print(result)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=0
if n<10**8:
  if n%2==0:
    for i in range(1,n-1,2):
      sum3=0
      sum5=0
      sum7=0
      x=str(i)
      l=len(x)
      for j in range(l):
        if x[j]=='3':
          sum3 += 1
        elif x[j]=='5':
          sum5 += 1
        elif x[j]=='7':
          sum7 += 1
        if (sum3 + sum5 + sum7 == l) and (sum3>0) and(sum5>0) and (sum7>0):
          ans+=1
  else:
    for i in range(1,n,2):
      sum3=0
      sum5=0
      sum7=0
      x=str(i)
      l=len(x)
      for j in range(l):
        if x[j]=='3':
          sum3 += 1
        elif x[j]=='5':
          sum5 += 1
        elif x[j]=='7':
          sum7 += 1
        if (sum3+sum5+sum7==l) and (sum3>0) and(sum5>0) and (sum7>0):
          ans+=1
  print(ans)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
i=input("")
i=int(i)
q=0
k=0
j=[]
for k in range(0,i+1) :
    j.clear()
    while k>0 :
        j.append(k%10)
        k //= 10

    
    if 1  not in j and 2  not in j and 4  not in j  and 6  not in j and 8  not in j and 9  not in j not in j:
        if 3 in j:
            if 7 in j :
                if 5 in j :
                    q=q+1


print(q)

Submission status: Wrong Answer

Solution code:
n=int(input())
temp=["3","5","7"]
sgs=[]
while len(temp[0])<len(str(n)):
	data=temp.pop(0)
	temp.append(data+"3")
	temp.append(data+"5")
	temp.append(data+"7")
	if data.count("3")==0 or data.count("5")==0 or data.count("7")==0:
		pass
	else:
		sgs.append(int(data))
for i in range(len(temp)):
	if temp[i].count("3")==0 or temp[i].count("5")==0 or temp[i].count("7")==0 or sgs.count(temp[i])>0:
		pass
	else:
		sgs.append(int(temp[i]))
sgs.sort()
cont=0
for i in range(len(sgs)-1):
	if sgs[i]==sgs[i+1] and i!=len(sgs)-2:
		pass
	elif sgs[i]>n:
		print(cont)
		break
	else:
		cont+=1