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:
import itertools as it

n = input()
ans = 0
nums = ['3', '7', '5']

for j in range(1, len(n) + 1):
    for i in it.product(nums, repeat=j):
        if int(n) >= int("".join(i)) and '3' in i and '5' in i and '7' in i:
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
t = [3, 5, 7]
while len(t) > 0:
    x = t.pop(0)
    if x * 10 + 3 <= n:
        t.append(x * 10 + 3)
        if x * 10 + 5 <= n:
            t.append(x * 10 + 5)
            if x * 10 + 7 <= n:
                t.append(x * 10 + 7)
    if 357 <= x <= n:
        s = str(x)
        if '3' in s and '5' in s and '7' in s:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
#encoidng utf-8

n = int(input())

for i in range(10):
    if 10**i > n:
        break
max_digit = i
# print(max_digit)
num_list = list("753")

def check(nums):
    value = False
    nums_list = list(str(nums))
    # print(nums)
    if (str(3) in nums_list) and (str(5) in nums_list) and (str(7) in nums_list):
        if nums <= n:
            value = True
            # print("::::clear")
    return value

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

#指定された桁数においてNより小さい数字の７５３を探す
def find_num(digit):
    count = 0
    for i in range(1,3**(digit)):

        pre_3 = Base_10_to_n(i,3)
        pre_3 = int(pre_3)
        # print(type(pre_3))
        meta='{0:0'+str(digit)+'d}'
        pre_3 = meta.format(pre_3)
        # print(pre_3)
        pre_3_list = list(pre_3)
        predict_num = []
        # print(pre_3_list)1234
        for i in range(len(pre_3_list)):
            if pre_3_list[i] == "0":
                predict_num.append("3")
            elif pre_3_list[i] == "1":
                predict_num.append("5")
            else:
                predict_num.append("7")
        # print("".join(predict_num))
        nums_pre = "".join(predict_num)
        if check(int(nums_pre)):
            count += 1
    return count

count = 0
for i in range(3,max_digit+1):
    count += find_num(i)
print(count)

Submission status: Accepted

Solution code:
N = int(input())
digits = ['3','5','7']
count = 0
ret = []
s = ''
def saiki(keta, moji):
    if keta == 0:
        return
    keta = keta - 1
    for d in digits:
        ret.append(moji+d)
        saiki(keta, moji+d)

saiki(11, s)
for i in ret:
    if '3' in i and '5' in i and '7' in i:
        if int(i) <= N:
            count += 1
print(count)