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:
import numpy as np

def count(n,s):
    if s == 0:
        return 3**n - 3*(2**n) + 3
    elif s == 1:
        return 3**n - 2**(n+1) + 1
    elif s == 2:
        return 3**n - 2**n
    else:
        return 3**n

def num753(Nlist, appeared):
    n = len(Nlist)
    if n == 0:
        if appeared == 7:
            return 1
        else:
            return 0
    
    top = Nlist[-1]
    
    ap3 = appeared|1
    s3 = ap3 % 2 + (ap3 % 4)//2 + ap3 // 4
    ap5 = appeared|2
    s5 = ap5 % 2 + (ap5 % 4)//2 + ap5 // 4
    ap7 = appeared|4
    s7 = ap7 % 2 + (ap7 % 4)//2 + ap7 // 4

    if appeared == 0:
        ans = sum([count(i,0) for i in range(3,n)])
    else:
        ans = 0

    if top == 3:
        ans = ans + num753(Nlist[:-1],ap3)
    elif top == 4:
        ans = ans + count(n-1,s3)
    elif top == 5:
        ans = ans + count(n-1,s3) + num753(Nlist[:-1],ap5)
    elif top == 6:
        ans = ans + count(n-1,s3) + count(n-1,s5)
    elif top == 7:
        ans = ans + count(n-1,s3) + count(n-1,s5) + num753(Nlist[:-1],ap7)
    else: # top == 8,9
        ans = ans + count(n-1,s3) + count(n-1,s5) + count(n-1,s7)
    
    return ans

N = int(input())
Nlist=[]
while N > 0:
    Nlist.append(N % 10)
    N = N // 10
Nlist = np.array(Nlist,dtype=np.int)

print(num753(Nlist,0))

Submission status: Wrong Answer

Solution code:
N = int(input())

i = 357
count = 0
if 357 <= N:
    while(1):
        print(i)
        flag = 0
        flag7 = 0
        flag5 = 0
        flag3 = 0
        for j,s in enumerate(str(i)):
            if s != "7" and s != "5" and s != "3":
                flag = 1
                i += 10 ** (len(str(i)) - j - 1)
                break
            if s == "7":
                flag7 = 1
            elif s == "5":
                flag5 = 1
            elif s == "3":
                flag3 = 1
        if flag == 0 and flag7 == 1 and flag5 == 1 and flag3 == 1:
            count += 1
        if flag == 0:
            i += 1
        if N <= i:
            break

print(count)

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

    if inn >= 533333337:
        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

    if inn >= 733333335:
        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

    print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = len(str(n))
ans = 0

# 当該桁数の七五三数を列挙
for i in range(10**(d-1)*3+1,max(10**(d-1)*8,n)+1,2):
    if {'3','5','7'} == set(str(i)):
        ans += 1

# 当該桁までの七五三数を計算
for i in range(3,d):
    ans += 3 + 3**i - 3*2**i

print(ans)

Submission status: Wrong Answer

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

for n in range(N):
    if all(x in str(n) for x in (str(7), str(5), str(3))) and not any(x in str(n) 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:
n = int(input())
cnt = 0
for i in range(n):
    s = str(i)
    if (s.find('7') != -1) and (s.find('5') != -1) and (s.find('3') != -1):
        if s.replace('7','').replace('5','').replace('3','') == '':
            cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
str1 = input()

max = int(str1)
sum = 0

for i in range(357, max):
  str_i = str(i)
  if (str_i[0] == '8'):
    i = 3 * 10 ** len(str_i)
    continue
  if (('3' in str_i) & ('5' in str_i) & ('7' in str_i)):
    str_i = str_i.replace('3', '')
    str_i = str_i.replace('5', '')
    str_i = str_i.replace('7', '')
    if (len(str_i) == 0):
      sum += 1
    
print(sum)

Submission status: Wrong Answer

Solution code:
def is_753(x):
    number = [ele for ele in str(x)]
    seven = False
    five = False
    three = False

    while '7' in number:
        seven = True
        number.remove('7')
    if not seven:
        return False

    while '5' in number:
        five = True
        number.remove('5')
    if not five:
        return False

    while '3' in number:
        three = True
        number.remove('3')
    if not three:
        return False

    if number:
        return False
    else:
        return True

n = int(input())
n_str = [ele for ele in str(n)]


count = 0
for l in range(3, len(n_str)):
    # print("{}桁を考えます".format(l))
    count += l*(l-1)*(l-2) * int(pow(3, l-3))
# print(count)
for i in range(int(pow(10, len(n_str)-1)), n+1):
    # print("now looking {}".format(i))
    if is_753(i):
        # print("{} is 753".format(i))
        count+=1


print(count)

Submission status: Wrong Answer

Solution code:
ans = 0

def search(num, target):
  global ans
  if len(num) == len(target):
    if int(num) < int(target) and "3" in num and "5" in num and "7" in num:
      ans+=1
  else:
    search(num+"3", target)
    search(num+"5", target)
    search(num+"7", target)
  

N = input()
length = len(N)
for i in range(3, length):
  ans += 3**i - 3 * (2**i - 1)
  



    
search("", N)
    
if len(N) >= 3:
  print(ans)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
cnt=0
three=0
five=0
seven=0
for i in range(n):
  if ("3" in str(i)) and ("5" in str(i)) and ("7" in str(i)):
    if("1" in str(i)) or ("2" in str(i)) or ("4" in str(i)) or ("6" in str(i)) or ("8" in str(i)) or ("9" in str(i)) or ("0" in str(i)):
      continue
    else:
      cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
N=input()

def vary(x):
    y=str(x)
    a=y[0]
    b=y[1]
    c=y[2]
    if a==b:
        if b==c: return 1
        return 2
    else:
        if b==c or a==c: return 2
        return 3

def count(n):
    N=int(n)
    if N<357: return 0
    if len(n)==3:
        dig3=(357,375,537,573,735,753)
        s=0
        for d in dig3:
            if d>N: break
            s+=1
        return s
    
    dp=[[1,0,0]]
    for i in range(1,9):
        a1 = 1
        a2 = 2 + dp[i-1][1]*2
        a3 = dp[i-1][1]*3 + dp[i-1][2]*3
        dp.append([a1,a2,a3])
        
    u357=[]
    for i in [3,5,7]:
        for j in [3,5,7]:
            for k in [3,5,7]:
                u357.append(i*100+j*10+k)
    
    s=0
    p=len(n)
    
    for d in dp[:(p-1)]:
        s+=d[2]
        
    for u in u357:
        if u>int(n[:3]): break
        x=vary(u)
        if x==1: s=s+dp[p-4][2]+dp[p-4][1]
        elif x==2: s=s+dp[p-4][2]+dp[p-4][1]*2+dp[p-4][0]
        else: s=s+3**(p-3)
        
    return s

print(count(N))

Submission status: Wrong Answer

Solution code:
import math
count = 0
n = int(input())
# a = n%1000
# b = math.floor(n/1000)
# c=list(str(b))
# print(c)

for i in range(n):
    s = list(str(i))
    if '3' in s and '5' in s and '7' in s and not('0' in s or '1' in s or '2' in s or '4' in s or '6' in s or '8' in s or '9' in s):
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
ans = 0

def search(num, target):
  global ans
  if len(num) == len(target):
    if int(num) < int(target) and "3" in num and "5" in num and "7" in num:
      ans+=1
  else:
    search(num+"3", target)
    search(num+"5", target)
    search(num+"7", target)
  

N = input()
length = len(N)
for i in range(3, length):
  ans += 3**i - 3 * (2**i - 1)
  



    
search("", N)
    

print(ans)

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
        j.reverse()

    if 3 in j:
        if 5 in j :
            if 7 in j :
                q=q+1
            else:
                continue
print(q)

Submission status: Wrong Answer

Solution code:
import itertools
def calc_num(S,S_len):
    result = 0;
    l = [3,5,7];
    i = 3;
    while i <= S_len:
      for v in itertools.product(l,repeat=i):
        if int("".join(map(str, v))) >= S: 
          break;
        if list(set(v) & set(l)) == l: 
          result = result + 1;
      i = i + 1;
    return result
  
S = list(map(int,input()))
S_len = len(S);
S = int("".join(map(str, S)));
result = calc_num(S,S_len);
print(result)

Submission status: Wrong Answer

Solution code:
# 357
# 0,1,2
# 1000000000
#  777777753
N = int(input())
tfs = '0357'


count = 0
a = [0] * 6 + [1, 2, 3]
gen = int(''.join([tfs[i] for i in a]))
while gen < N:
    s = str(gen)
    if '3' in s and '5' in s and '7' in s:
        count += 1
    a[-1] += 1
    for i in range(len(a)):
        if a[len(a) - i - 1] > 3:
            a[len(a) - i - 1] = 1
            a[len(a) - i - 1 - 1] += 1
        else:
            gen = int(''.join([tfs[i] for i in a]))
            break


print(count)

Submission status: Wrong Answer

Solution code:
n = input()

c = len(n)
ans = 0 
for i in range(3,c):
    ans += 3**i - ((2**i -2)*3) -3


a = [3,5,7]

for i in range(c-1):
    b = []
    for num in a:
        for s in ["3","5","7"]:
            b.append(int(str(num) + s))
        
    for ke in b:
        a.append(ke)



for num in a:
    if num < int(n) and len(str(num)) == c:
        if str(num).count("3") >0 and str(num).count("5") >0 and str(num).count("7") >0 :
            
            ans += 1


print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math
a = int(input())
c = str(a)
b = 0
"""
if (b >= 357):    
    for i in range(357, a):
"""
keta = int (math.log10(a) + 1)
list = []
if a >= 357:
    count = 0
    for i in range(3, keta):
        c = 1
        b = 3
        for j in range(0, i):
            c *= 3
            b *= 2
        list.append(c - b +3)
    start = pow(10, keta - 1) * 3

    for i in range(start, a):
        flg3 = 0
        flg5 = 0
        flg7 = 0
        for j in range(0, keta):
            if (str(i)[j] == "3"):
                flg3 = 1
            elif (str(i)[j] == "5"):
                flg5 = 1
            elif (str(i)[j] == "7"):
                flg7 = 1
            else:
                break
            if (j == keta - 1 and flg3 == 1 and flg5 == 1 and flg7 == 1):
                count += 1
    b = count + sum(list)
print(b)

Submission status: Wrong Answer

Solution code:
def main():
	import numpy as np
	n = input()
	d = len(n)
	dd = np.zeros(d)
	for i in range(d):
		if(int(n[i]) >= 7):
			dd[i] = 3
		elif(int(n[i]) >= 5):
			dd[i] = 2
		elif(int(n[i]) >= 3):
			dd[i] = 1
		else:
			dd[i] = 0
	max = ""
	for i in range(d):
		if(dd[-i-1] == 3):
			max = "7"+max
		elif(dd[-i-1] == 2):
			max = "5"+max
		elif(dd[-i-1] == 1):
			max = "3"+max
		else:
			if(i != d-1):
				max = "7"+max
				dd[-i-1] -= 1

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

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

for i in range(1, n + 1, 2):
    t, f, s = 0, 0, 0
    num = list(str(i))
    while '3' in num:
        num.remove('3')
        t = 1
    while '5' in num:
        num.remove('5')
        f = 1
    while '7' in num:
        num.remove('7')
        s = 1
    if t == 1 and f == 1 and s == 1 and not num:
        print(i)
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
import itertools

N_st = input()
keta = len(N_st)
N = int(N_st)


hit53 =['3','5','7']
res = []

all_perm = []
for k in range(3,keta + 1):
    all_perm.extend(list(itertools.product(hit53,repeat= k)))
for a in all_perm:
    target = int(''.join(a))
    if target < N and '3' in str(target) and '5' in str(target) and '7' in str(target):
        res.append(target)

print(len(res))

Submission status: Wrong Answer

Solution code:
N = input().strip()

base = set(['375', '357', '537', '573', '735', '753'])

if int(N) < 357:
  print(0)
else:
  for n in range(len(N) - 3):
    newb = set()
    for b in base:
      new3b = set([b[:i] + '3' + b[i:] for i in range(len(b) + 1)])
      new5b = set([b[:i] + '5' + b[i:] for i in range(len(b) + 1)])
      new7b = set([b[:i] + '7' + b[i:] for i in range(len(b) + 1)])
      newb |= new3b | new5b | new7b
    base |= newb

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

Submission status: Wrong Answer

Solution code:
N = int(input())

i = 357
count = 0
if 357 <= N:
    while(1):
        print(i)
        flag = 0
        flag7 = 0
        flag5 = 0
        flag3 = 0
        for j,s in enumerate(str(i)):
            if s != "7" and s != "5" and s != "3":
                flag = 1
                i += 10 ** (len(str(i)) - j - 1)
                break
            if s == "7":
                flag7 = 1
            elif s == "5":
                flag5 = 1
            elif s == "3":
                flag3 = 1
        if flag == 0 and flag7 == 1 and flag5 == 1 and flag3 == 1:
            count += 1
        if flag == 0:
            i += 1
        if N < i:
            break

print(count)

Submission status: Wrong Answer

Solution code:
N = input()
length = len(N)
jogai = 0

def check(number):
    three = 0
    five = 0
    seven = 0
    for i in range(len(str(number))):
        if str(number)[i:i+1] == '3':
            three += 1
        elif str(number)[i:i+1] == '5':
            five += 1
        elif str(number)[i:i+1] == '7':
            seven += 1
        else:
            return False
    if three >= 1 and five >= 1 and seven >= 1:
        return True
    else:
        return False

if int(N) <= int('7'*length):
    for l in range(int(N)+1, int('7'*length)+1):
        if check(l):
            jogai += 1

print(3**length-3*2**length+3-jogai)

Submission status: Wrong Answer

Solution code:
N = input().strip()

base = set(['375', '357', '537', '573', '735', '753'])

if int(N) < 375:
  print(0)
else:
  for n in range(len(N) - 3):
    newb = set()
    for b in base:
      new3b = set([b[:i] + '3' + b[i:] for i in range(len(b) + 1)])
      new5b = set([b[:i] + '5' + b[i:] for i in range(len(b) + 1)])
      new7b = set([b[:i] + '7' + b[i:] for i in range(len(b) + 1)])
      newb |= new3b | new5b | new7b
    base |= newb
    
  
print(len([i for i in base if int(i) <= int(N)]))

Submission status: Wrong Answer

Solution code:
n = int(input())
array = []
for i in range(n+1):
    if str(i)in "7":
        if str(i) in "5":
            if str(i) in "3":
                if (str(i).count("3") + str(i).count("5") + str(i).count("7")) == len(str(i)):
                    array.append(i)
print(len(array))

Submission status: Wrong Answer

Solution code:
n = int(input())
array = []
for i in range(n+1):
    if str(i)in "7":
        if str(i) in "5":
            if str(i) in "3"> 0:
                if (str(i).count("3") + str(i).count("5") + str(i).count("7")) == len(str(i)):
                    array.append(i)
print(len(array))

Submission status: Wrong Answer

Solution code:
N = int(input())
i = 1
count = 0
if N >= 777777777:
    while i <= N:
        I = str(i)
        I = list(I)
        if I.count("3")>0 and I.count("5")>0 and I.count("7"):
            if I.count("0")==0 and I.count("1")==0 and I.count("2")==0 and I.count("4")==0 and I.count("6")==0 and I.count("8")==0 and I.count("9")==0:
                count+=1
                i+=1
            else:
                i+=1
        else:
            i+=1
    print(count)
else:
    print(26484)

Submission status: Wrong Answer

Solution code:
N = input().strip()

base = set(['375', '357', '537', '573', '735', '753'])

if int(N) < 375:
  print(0)
else:
  for n in range(len(N) - 3):
    newb = set()
    for b in base:
      new3b = set([b[:i] + '3' + b[i:] for i in range(len(b) + 1)])
      new5b = set([b[:i] + '5' + b[i:] for i in range(len(b) + 1)])
      new7b = set([b[:i] + '7' + b[i:] for i in range(len(b) + 1)])
      newb |= new3b | new5b | new7b
    base |= newb
    
  
print(len([i for i in base if int(i) < int(N)]))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = ['3','5','7']
el = ['0','1','2','4','6','8','9']
res = 0

for i in range(357,n+1):
    #print(i)
    n = list(str(i))
    if ("3" in n and "5" in n and "7" in n) and (str(i) not in el):
        res += 1
else:
    print(res)

Submission status: Wrong Answer

Solution code:
S = input()
D = len(S)
N = int(S)

if D <= 2:
    print(0)
    exit(0)

lst = [[], [], [], ["357", "375", "537", "573", "735", "753"]]
for d in range(4, D + 1):
    prev = lst[d - 1]
    lstd = []
    for si in prev:
        for i in range(len(si) + 1):
            lstd.append(si[:i] + '3' + si[i:])
            lstd.append(si[:i] + '5' + si[i:])
            lstd.append(si[:i] + '7' + si[i:])
    lst.append(list(set(lstd)))

count = 0
for i in range(3, D):
    se = set(lst[i])
    count += len(se)

lstd = [int(i) for i in list(set(lst[D]))]
lstd.sort()

import bisect
count += bisect.bisect_left(lstd, N)
print(count)

Submission status: Wrong Answer

Solution code:
N=int(raw_input())

sum = 0
#flag = 0
sample = set(['7', '5', '3'])

for i in range(3,N+1,10):
#    flag = 0
#    print str(i)

    nums = set(list(str(i)))

    if sample.issubset(nums) and len(nums.difference(sample)) == 0:
        print i
        sum += 1
for i in range(5,N+1,10):
#    flag = 0
#    print str(i)

    nums = set(list(str(i)))

    if sample.issubset(nums) and len(nums.difference(sample)) == 0:
        print i
        sum += 1
for i in range(7,N+1,10):
#    flag = 0
#    print str(i)

    nums = set(list(str(i)))

    if sample.issubset(nums) and len(nums.difference(sample)) == 0:
        print i
        sum += 1


print sum

Submission status: Wrong Answer

Solution code:
n = int(input())

def issft(number):
    t = 0
    f = 0
    s = 0
    for i in range(len(str(number))):
        w = str(number)[i]
        if w == "3":
            t = 1
        elif w == "5":
            f = 1
        elif w == "7":
            s = 1
        else:
            return False
    if t == 1 and f == 1 and s == 1:
        return True
    else:
        return False

count = 0
for k in range(int((n +n%2)/2-100)):
    w = k*2 + 101
    if issft(w):
        count+= 1
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
array = []
for i in range(n+1):
    if str(i).count("3") > 0:
        if str(i).count("5") > 0:
            if str(i).count("7") > 0:
                if (str(i).count("3") + str(i).count("5") + str(i).count("7")) == len(str(i)):
                    array.append(i)
print(array)

Submission status: Wrong Answer

Solution code:
n = int(input())

def issft(number):
    t = 0
    f = 0
    s = 0
    for i in range(len(str(number))):
        w = str(number)[i]
        if w == "3":
            t = 1
        elif w == "5":
            f = 1
        elif w == "7":
            s = 1
        else:
            return False
    if t == 1 and f == 1 and s == 1:
        return True
    else:
        return False

count = 0
for k in range(int((n - n%2)/2-100)):
    w = k*2 + 101
    if issft(w):
        count+= 1
print(count)

Submission status: Wrong Answer

Solution code:
import itertools
n=int(input())
h = list(itertools.product(['7','5','3'],repeat=len(str(n))))
s=[0, 0, 0, 6, 36, 150, 540, 1806, 5796, 18150]
cnt=sum(s[:len(str(n))])
if n < 100:
    print(0)
else:
    for i in h:
        if any([j not in i for j in ['7','5','3']]):
            continue
        else:
            t=int(''.join(i))
            if n >= t:
                cnt+=1

print(cnt)

Submission status: Wrong Answer

Solution code:
from math import log10

def cal(num,tup,k,max_,arr):
    r=0
    if k<0:
        if num < max_ and arr[0]*arr[1]*arr[2]>0:
            return 1
        else:
            return 0
    for i,x in enumerate(tup):
        arr[i]+=1
        r+=cal(num+x*10**k,tup,k-1,max_,arr)
        arr[i]-=1
    return r

def fac(n):
    t=1
    for i in range(2,n+1):
        t*=i
    return t

N=int(input())
k=int(log10(N))

tup=(3,5,7)

ans=0
for i in range(2,k+1):
    ans+=cal(0,tup,i,N,[0,0,0])
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

base = ["3", "5", "7"]
nums = ["3", "5", "7"]
temp = []
x = 0

while 1:
    for num in nums[(3**x)-1:]:
        for b in base:
            temp.append(b + num)
    nums.extend(temp)
    
    x += 1
    if int(temp[-1]) > 10**9:
        break
    temp = []

target = []
for n in set(nums):
    if "7" in n and "5" in n and "3" in n:
        target.append(int(n))

count = 0
target.sort()
for n in target:
    if int(n) < N:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())

cnt = 0
i = 1
while i < n:
    is_broken = False
    string = list(str(i))
    for j, s in enumerate(string):
        if s not in ['3', '5', '7']:
            i = i + 10**(len(string) - j - 1)
            is_broken = True
            break
    if is_broken:
        continue

    c1 = string.count('3') >= 1
    c2 = string.count('5') >= 1
    c3 = string.count('7') >= 1
    if c1 and c2 and c3:
        cnt += 1

    i += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
import re

inn = int(input())

result = 0

if inn < 357:
    print(0)

else:
    for i in range(357, inn):

        str_i = str(i)

        if '3' in str_i and '5' in str_i and '7' in str_i:
            str_i = str_i.replace('3', '')
            str_i = str_i.replace('5', '')
            str_i = str_i.replace('7', '')

            str_i = re.sub(r'3|5|7', '', str_i)

            if str_i == '':
                result += 1

    print(result)

Submission status: Wrong Answer

Solution code:
import itertools
print(1)

Submission status: Wrong Answer

Solution code:
import math
print(math.factorial(5))

Submission status: Wrong Answer

Solution code:
n = int(input())
array = []
for i in range(n+1):
    if (str(i).count("3") + str(i).count("5") + str(i).count("7")) == len(str(i)):
        array.append(i)
print(len(array))

Submission status: Wrong Answer

Solution code:
N=int(input())

import itertools

ITER=[]
for i in range(3,10):
    ITER+=list(itertools.product([3,5,7],repeat=i))

def number(iter):
    
    s=""
    for l in iter:
        s+=str(l)
    return  int(s)
    
ANS=0
for iter in ITER:
    if 3 in iter and 5 in iter and 7 in iter:
        if number(iter)<N:
            ANS+=1

print(ANS)

Submission status: Wrong Answer

Solution code:
N=int(input())
ans=[]

for i in range(N):
    a=str(i)
    l=list(a)
    lst=list(set(l))
    if lst==["3","5","7"]:
        ans.append(1)

print(len(ans))

Submission status: Wrong Answer

Solution code:
from sys import stdin
N=int(stdin.readline().rstrip())
cnt=0
for i in range(N):
    if set(list(str(i)))=={"3","5","7"}:
        cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
print(len([i for i in range(int(input())) if "7" in str(i) and "5" in str(i) and "3" in str(i) and "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)]))

Submission status: Wrong Answer

Solution code:
N = int(input())

i = 357
count = 0
if 357 <= N:
    while(1):
        flag = 0
        flag7 = 0
        flag5 = 0
        flag3 = 0

        for j,s in enumerate(str(i)):
            if s != "7" and s != "5" and s != "3":
                flag = 1
                i += 10 ** (len(str(i)) - j - 1)
                break
            if s == "7":
                flag7 = 1
            elif s == "5":
                flag5 = 1
            elif s == "3":
                flag3 = 1
        if flag == 0 and flag7 == 1 and flag5 == 1 and flag3 == 1:
            count += 1
        if flag == 0:
            i += 1
        if N <= i:
            break

print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())

i = 357
count = 0
if 357 <= N:
    while(1):
        flag = 0
        flag7 = 0
        flag5 = 0
        flag3 = 0

        for j,s in enumerate(str(i)):
            if s != "7" and s != "5" and s != "3":
                flag = 1
                i += 10 ** (len(str(i)) - j - 1)
                break
            if s == "7":
                flag7 = 1
            elif s == "5":
                flag5 = 1
            elif s == "3":
                flag3 = 1
        if flag == 0 and flag7 == 1 and flag5 == 1 and flag3 == 1:
            count += 1
            print(str(i))
        if flag == 0:
            i += 1
        if N <= i:
            break

print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())

base = ["3", "5", "7"]
nums = ["3", "5", "7"]
temp = []
x = 0

while 1:
    for num in nums:
        for b in base:
            temp.append(b + num)
    nums.extend(temp)
    
    x += 1
    if int(temp[-1]) > 10**9:
        break
    temp = []

target = []
for n in set(nums):
    if "7" in n and "5" in n and "3" in n:
        target.append(n)

count = 0
for n in target:
    if int(n) < N:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=0
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)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 0
for i in range(0,n):
    stringi = str(i)
    iselse = False
    if '7' in stringi and '5' in stringi and '3' in stringi:
        if '0' not in stringi:
            if '1' not in stringi:
                if '2' not in stringi:
                    if  '4' not in stringi:
                         if '6' not in stringi:
                             if '8' not in stringi:
                                 if '9' not in stringi:
                                    ans += 1
print(ans)

Submission status: Wrong Answer

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

for n in range(N):
    if all(x in str(n) for x in (str(7), str(5), str(3))) and not any(x in str(n) for x in (str(0), str(1), str(2), str(4), str(6), str(8), str(9))):
        N_753.append(n)
print(len(N_753))

Submission status: Wrong Answer

Solution code:
import itertools, operator
def combinations_with_replacement_counts(n, r):
    size = n + r - 1
    for indices in itertools.combinations(range(size), n-1):
        starts = [0] + [index+1 for index in indices]
        stops = indices + (size,)
        yield tuple(map(operator.sub, stops, starts))
        
a = (input())
ok = dict()
aller = list(range(len(a)))
out = 0
if len(a) <= 2:
	print(0)
if len(a) >= 3:
	num = int(a)
	for times in range(len(a) - 3):
		no = list(range(times + 3))
		for i in combinations_with_replacement_counts(3, times):
			for j in itertools.combinations(no, i[0] + 1):
				for k in itertools.combinations([ele for ele in no if ele not in j], i[1] +1):
					for l in itertools.combinations([ele for ele in no if ele not in j and ele not in k], i[2] + 1):
						print(j,k,l)
						out += 1
					
	for i in combinations_with_replacement_counts(3, len(a) - 3):
		for j in itertools.combinations(aller, i[0] + 1):
			for k in itertools.combinations([ele for ele in aller if ele not in j], i[1] +1):
				for l in itertools.combinations([ele for ele in aller if ele not in j and ele not in k], i[2] + 1):
					number = sum([3*10**ele for ele in j]) +sum([5*10**ele for ele in k]) + sum([7*10**ele for ele in l])
					if number <= num:
						out += 1
	print(out)

Submission status: Wrong Answer

Solution code:
N = int(input())

base = ["3", "5", "7"]
nums = ["3", "5", "7"]
temp = []
x = 0

while 1:
    for num in nums[(3**x)-1:]:
        for b in base:
            temp.append(b + num)
    nums.extend(temp)
    
    x += 1
    if int(temp[-1]) > 10**9:
        break
    temp = []

target = []
for n in set(nums):
    if "7" in n and "5" in n and "3" in n:
        target.append(n)

count = 0
for n in target:
    if int(n) < N:
        count += 1

print(count)