1. Title Description: Click to open the link
2. Problem-solving ideas: the subject of the need to find out the lucky number of the subscript. This is similar to the purple book on an example ugly number. The use of BFS can be solved. First, 4, 7 into the queue, each out of the queue, the number is added to the set, at the same time, add the end of each of them is 4,7 after the new lucky number into the queue can be. The above process after the table, the direct output can.
3. Code:
#define _crt_secure_no_warnings #include <iostream> #include <algorithm> #include <string> #include <sstream> #include <set> #include <vector> #include <stack> #include <map> #include < queue> #include <deque> #include <cstdlib> #include <cstdio> #include <cstring> #include < cmath> #include <ctime> #include <functional>using namespace std; #define INF 100000000#define for (i,n) for (int i=0;i< (n); i++) typedef long LONG ll;const int n = 1000000000 + 5;set<ll>a;void init () {int cnt = 1;QUEUE< ; Ll>q;q.push (4); Q.push (7); while (!q.empty ()) {ll u = Q.front (); Q.pop (); if (U > 1000000000) break;a.insert (U); ll u1 = u * + 4, U2 = U * Ten + 7;q.push (U1); Q.push (U2);}} int main () {//freopen ("T.txt", "R", stdin), ll N;init (); while (~SCANF ("%i64d", &n)) {Set<ll>::iterator it ; it = A.find (n); cout << distance (A.begin (), it) + 1 << Endl;} return 0;}
#299 (Div.2) b. Tavas and Saddas