やるだけ
set<int> s; const int N = 1000000; void rec(int n) { if (N <= n) return ; s.insert(n); rec(n * 10 + 4); rec(n * 10 + 7); return ; } class TheLargestLuckyNumber { public: int find(int n) { rec(0); int ret = -1; FOR (i, s) { if (n < *i) break; ret = *i; } return ret; } };