#include #include #include using namespace std; vector f; vector res; int comp_f(int x) { if (x < f.size()) { return f[x]; } else { return comp_f(x % 10) + comp_f(floor(x / 10.0)); } } int try_comp(int x) { for (int i = 1; i < f.size(); i++) { if (f[i] == x) { res.push_back(i); return f[i]; } if (f[i] > x) { res.push_back(i - 1); return try_comp(x - f[i - 1]); } } } int main() { int y; cin >> y; f.push_back(1); f.push_back(1); f.push_back(2); f.push_back(6); f.push_back(24); f.push_back(120); f.push_back(720); f.push_back(5040); f.push_back(40320); f.push_back(362880); /* cout << comp_f(y) << endl;*/ try_comp(y); for (int i = res.size() - 1; i >= 0; i--) { cout << res[i]; } cout << endl; /* for (int x = 20; x < 21; x++) { if (x < f.size()) { cout << f[x] << endl; } else { int res = comp_f(x); cout << res << endl; f.push_back(res); } } */ return 0; }