I found my mistake while I was watching the blog of the roll god.
# Include <cstdio> # include <cstring> # include <cmath> # include <algorithm> # include <climits> # include <string> # include <iostream> # include <map> # include <cstdlib> # include <list> # include <set> # include <queue> # include <stack> using namespace STD; typedef long ll; ll ans; const ll mod = 1000000007; ll DP [100] [100]; ll up [1000]; ll hash [100]; ll DFS (LL now, ll sum, ll flag) {If (sum> ans) return 0; If (now <= 0) retu Rn sum = ans; If (! Flag &&~ DP [now] [Sum]) return DP [now] [Sum]; ll Limit = flag? Up [now]: 9, ret = 0; For (ll I = 0; I <= limit; I ++) {if (I = 4 | I = 7) RET + = DFS (now-1, sum + 1, flag & I = Limit ); else RET + = DFS (now-1, sum, flag & I = Limit);} return flag? RET: DP [now] [Sum] = ret;} ll solve (ll x) {ll Len = 0; while (X) {up [++ Len] = x % 10; X/= 10;} return DFS (Len, 0, 1);} ll Len; ll ans1 = 0; void Gao (ll dep, ll left, ll W) {w % = MOD; If (DEP = 0) {ans1 + = W; ans1 % = MOD; return ;} for (ll I = 0; I <= left; I ++) {If (hash [I]) Gao (dep-1, left-I, W * hash [I] --), hash [I] ++ ;}} int main () {ll N; CIN> N; memset (hash, 0, sizeof (hash); For (ANS = 0; ans <10; ans ++) {memset (DP,-1, sizeof (DP); // You Need to reinitialize it. Hash [ANS] = solve (N)-solve (0);} Len = 10; while (! Hash [Len]) Len --; For (ll I = 1; I <= Len; I ++) if (hash [I]) Gao (6, I-1, hash [I]); cout <ans1 <Endl; return 0 ;}