category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

D - Multiply and Rotate

implementation ```cpp ll a, n; cin >> a >> n; queue qu; vector distance(1000005, -1); qu.push(1); distance[1] = 0; while (!qu.empty()) { auto u = qu.front(); qu.pop(); ll v = 1LL * u * a; if (v < 1e6 and distance[v] == -1) { qu.push(v); distance[v] = distance[u] + 1; } if (u >= 10 and u % 10 != 0) { v = (u % 10) * pow(10, digits(u / 10 - 1)) + u / 10; if (v < 1e6 and distance[v] == -1) { qu.push(v); distance[v] = distance[u] + 1; } } } cout << distance[n] << '\n'; ``` </details>