#include #include #include #include using namespace std; int main() { set st; priority_queue, greater> pq; const int ok[3] = {3, 5, 7}; st.insert(1); pq.push(1); int times = 0; while (true) { long long lucky = pq.top(); pq.pop(); if (lucky == 59084709587505) { //49 cout << times << endl; return 0; } times++; for (int i = 0; i < 3; i++) { long long b = lucky * ok[i]; if (!st.count(b)) { st.insert(b); pq.push(b); } } } return 0; }