Language: C++

#include<iostream>
#include<string>
#include<cstdlib>
#include <vector>
using namespace std;
int pow(int n){
    if(n==0)return 1;
    else return pow(n-1)*10;
}
int pow3(int n){
    if(n==0)return 1;
    else return pow(n-1)*3;
}
int decode(int code){
    if(code == 0)return 3;
    if(code == 1)return 5;
    if(code == 2)return 7;
    return (code % 3)*2+3+decode(code/3)*10;
}
int _isSft(int value, int seven, int five, int three){
    if(value==0){
        return seven&&five&&three;
    }
    int tail=value%10;
    int head=value/10;
    if(tail == 7)return _isSft(head, 1, five,three);
    if(tail == 5)return _isSft(head, seven, 1,three);
    else return _isSft(head, seven, five,1);
}
int isSft(int value){
    return _isSft(value,0,0,0);
}
int rank(int N){
    if(N==0)return 0;
    else return rank(N/10)+1;
}
int head(int N){
    if(N<10)return N;
    else return head(N/10);
}
int tail(int N){
    return N % pow(rank(N)-1);
}
int get(int rank, int N){
    return (N/pow(rank))%10;
}
vector<vector<vector<vector<int>>>> memo= new vector<vector<vector<vector<int>>>>(10,
new vector<vector<vector<int>>>(2,
new vector<vector<int>>(2,
new vector<int> (2))));
//no limit
int solve(int order, int seven, int five, int three){
    if(memo[order][seven][five][three]!=0)return memo[order][seven][five][three];
    if(order==0)return seven&&five&&three?1:0;
    else return solve( order-1, 1, five, three)
    +solve( order-1, seven, 1, three)
    +solve( order-1, seven, five, 1);
}
//limit
int solve(int order, int N, int seven, int five, int three){
    if(order==0)return seven&&five&&three?1:0;
    else {
        int headN= head(N);
        int tailN=tail(N);
        if(headN>=8)
        return solve( order-1, 1, five, three)
        +solve( order-1, seven, 1, three)
        +solve( order-1, seven, five, 1);
        if(headN==7)    
        return solve(order-1, tailN, 1, five, three)
        +solve(order-1, seven, 1, three)
        +solve(order-1, seven, five, 1);
        if(headN==6)    
        return solve(order-1, seven, 1, three)
        +solve(order-1, seven, five, 1);
        if(headN==5)    
        return solve(order-1, tailN, seven, 1, three)
        +solve(order-1, seven, five, 1);
        if(headN==4)    
        return solve(order-1, seven, five, 1);
        if(headN==3)    
        return solve(order-1, tailN, seven, five, 1);
        else return 0;
    }
}
int main(){
    int N;
    cin>>N;
    int NnoRank = rank(N);
    int sum =0;
    for(int i=1;i<=NnoRank;i++){
        sum+=solve(i,N);
    }
    cout<<solve(9,N)<<endl;
}

Compiler output:
a.cc: In function 'int rank(int)':
a.cc:35:17: error: reference to 'rank' is ambiguous
   35 |     else return rank(N/10)+1;
      |                 ^~~~
In file included from /usr/include/c++/14/bits/move.h:37,
                 from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:33:5: note:                 'int rank(int)'
   33 | int rank(int N){
      |     ^~~~
a.cc: In function 'int tail(int)':
a.cc:42:20: error: reference to 'rank' is ambiguous
   42 |     return N % pow(rank(N)-1);
      |                    ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:33:5: note:                 'int rank(int)'
   33 | int rank(int N){
      |     ^~~~
a.cc: At global scope:
a.cc:50:20: error: no matching function for call to 'std::vector<std::vector<int> >::vector(int, std::vector<int>*)'
   50 | new vector<int> (2))));
      |                    ^
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]'
  707 |         vector(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:707:9: note:   template argument deduction/substitution failed:
a.cc:50:20: note:   deduced conflicting types for parameter '_InputIterator' ('int' and 'std::vector<int>*')
   50 | new vector<int> (2))));
      |                    ^
/usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; allocator_type = std::allocator<std::vector<int> >]'
  678 |       vector(initializer_list<value_type> __l,
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:678:43: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<std::vector<int> >'
  678 |       vector(initializer_list<value_type> __l,
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<int> >]'
  659 |       vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:659:23: note:   no known conversion for argument 1 from 'int' to 'std::vector<std::vector<int> >&&'
  659 |       vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
      |              ~~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; allocator_type = std::allocator<std::vector<int> >; std::false_type = std::false_type]'
  640 |       vector(vector&& __rv, const allocator_type& __m, false_type)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; allocator_type = std::allocator<std::vector<int> >; std::true_type = std::true_type]'
  635 |       vector(vector&& __rv, const allocator_type& __m, true_type) noexcept
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:635:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<int> >]'
  624 |       vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:624:28: note:   no known conversion for argument 1 from 'int' to 'const std::vector<std::vector<int> >&'
  624 |       vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
      |              ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]'
  620 |       vector(vector&&) noexcept = default;
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]'
  601 |       vector(const vector& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:601:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; size_type = long unsigned int; value_type = std::vector<int>; allocator_type = std::allocator<std::vector<int> >]'
  569 |       vector(size_type __n, const value_type& __value,
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:569:47: note:   no known conversion for argument 2 from 'std::vector<int>*' to 'const std::vector<std::vector<int> >::value_type&' {aka 'const std::vector<int>&'}
  569 |       vector(size_type __n, const value_type& __value,
      |                             ~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; size_type = long unsigned int; allocator_type = std::allocator<std::vector<int> >]'
  556 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:51: note:   no known conversion for argument 2 from 'std::vector<int>*' to 'const std::vector<std::vector<int> >::allocator_type&' {aka 'const std::allocator<std::vector<int> >&'}
  556 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |                             ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; allocator_type = std::allocator<std::vector<int> >]'
  542 |       vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]'
  531 |       vector() = default;
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:531:7: note:   candidate expects 0 arguments, 2 provided
a.cc: In function 'int main()':
a.cc:89:19: error: reference to 'rank' is ambiguous
   89 |     int NnoRank = rank(N);
      |                   ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:33:5: note:                 'int rank(int)'
   33 | int rank(int N){
      |     ^~~~
a.cc:92:19: error: no matching function for call to 'solve(int&, int&)'
   92 |         sum+=solve(i,N);
      |              ~~~~~^~~~~
a.cc:52:5: note: candidate: 'int solve(int, int, int, int)'
   52 | int solve(int order, int seven, int five, int three){
      |     ^~~~~
a.cc:52:5: note:   candidate expects 4 arguments, 2 provided
a.cc:60:5: note: candidate: 'int solve(int, int, int, int, int)'
   60 | int solve(int order, int N, int seven, int five, int three){
      |     ^~~~~
a.cc:60:5: note:   candidate expects 5 arguments, 2 provided
a.cc:94:16: error: no matching function for call to 'solve(int, int&)'
   94 |     cout<<solve(9,N)<<endl;
      |           ~~~~~^~~~~
a.cc:52:5: note: candidate: 'int solve(int, int, int, int)'
   52 | int solve(int order, int seven, int five, int three){
      |     ^~~~~
a.cc:52:5: note:   candidate expects 4 arguments, 2 provided
a.cc:60:5: note: candidate: 'int solve(int, int, int, int, int)'
   60 | int solve(int order, int N, int seven, int five, int three){
      |     ^~~~~
a.cc:60:5: note:   candidate expects 5 arguments, 2 provided