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:
N=999999999
l=len(str(N))

def calc(st):
    st=str(st)
    if(len(st)>l):return 0
    t=calc(st+"3")
    f=calc(st+"5")
    s=calc(st+"7")
    o=0
    if(st.find("7")>=0 and st.find("5")>=0 and st.find("3")>=0 and int(st)<=N):
        o=1
    return (t+f+s+o)

print(calc(str()))

Submission status: Wrong Answer

Solution code:
import itertools

N = input()
count = 0
list = ["3", "5", "7"]

for i in range(3, len(N)):
    # print(3**i - (2**i) * 3)
    count += 3**i - (2**i) * 3 + 3
# print(count)
for i in itertools.product(list, repeat=len(N)):
    if int("".join(i)) < int(N):
        if "3" in i and "5" in i and "7" in i:
            # print("".join(i))
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import itertools

N = input()
count = 0
list = ["3", "5", "7"]

for i in range(3, len(N)):
    # print(3**i - (2**i) * 3)
    count += 3**i - (2**i) * 3 + 3
# print(count)
for i in itertools.product(list, repeat=len(N)):
    if int("".join(i)) < int(N):
        if "3" in i and "5" in i and "7" in i:
            # print("".join(i))
            count += 1
    else:
        break
print(count)

Submission status: Wrong Answer

Solution code:
import itertools

N = input()
count = 0
list = ["3", "5", "7"]

if int(N) < 357:
    print(0)
else:
    for i in range(3, len(N)):
        # print(3**i - (2**i) * 3)
        count += 3**i - (2**i) * 3 + 3
    # print(count)
    for i in itertools.product(list, repeat=len(N)):
        if int("".join(i)) < int(N):
            if "3" in i and "5" in i and "7" in i:
                # print("".join(i))
                count += 1
        else:
            break
    print(count)

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N = input()
    NN = int(N)
    l = len(N)

    count = 0

    for i in range(1,l):
        count += 3**i 
        count -= 2**i * 3
        count += 3

    candidates = product(["3","5","7"], repeat=l)
    candidates = map(lambda x: "".join(x), candidates)
    candidates = filter(lambda x: len(set(x)) == 3, candidates)
    candidates = filter(lambda x: x < N, candidates)
    candidates = list(candidates)

    print(count + len(candidates))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
sitigosan_list = [3, 5, 7]
count = 0

if n < 357:
    print(0)

def make_753(num):
    a = str(num)
    b = a + '3'
    c = a + '5'
    d = a + '7'
    sitigosan_list.append(int(b))
    sitigosan_list.append(int(c))
    sitigosan_list.append(int(d))


for i in sitigosan_list:
    make_753(i)
    if max(sitigosan_list) > n:
        break

for j in sitigosan_list:
    if '3' in str(j) and '5' in str(j) and '7' in str(j) and j <= n:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
from itertools import product
N = int(input())
ans = 0
for p in product(['0','3','5','7'],repeat=9):
  s = ''.join(p)
  if '3' in s and '5' in s and '7' in s and int(s) <= N:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())
N_str = str(N)

ans=0
num = ["0","3","5","7"]
for s in itertools.product(num,num,num,num,num,num,num,num,num):
    n = int("".join(s))
    c3 = str(s).count("3")
    c5 = str(s).count("5")
    c7 = str(s).count("7")
    #print(s,n,c3,c5,c7)
    if n < N and c3>=1 and c5>=1 and c7>=1 and c3+c5+c7==len(str(n)):
        ans+=1
    elif n>N:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
#再帰関数
N = int(input())
def sft(s):
    if int(s) > N:
        return 0
    cnt = 1 if all(s.count(c)>0 for c in '753') else 0
    print(cnt)
    for c in '753':
        cnt += sft(s+c)
    return cnt
    
print(sft('0'))

Submission status: Wrong Answer

Solution code:
N = int(input())
n = ["3", "5", "7"]
l = 0
r = 3
x = 1
flag = True
while flag:
    for m in (3, 5, 7):
        if not flag:
            break
        for i in range(l, r):
            y = int(n[i])+m*10**x
            if y > N:
                flag = False
                break
            n.append(str(y))

    l = r + 1
    r = len(n)   
    x += 1

res = 0
for s in n:
    if "3" in s and "5" in s and "7" in s:
        res += 1

print(res)