func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T>   inline T sqr(T x) {     return x * x;   }   const double EPS = 1e-6;   const int INF = 0x3fffffff;   const long long LINF = INF * 1ll * INF;   const double PI = acos(-1.0);   using namespace std;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long d[400005];   long long a, b, k, lcm;   long long bfs(long long a, long long target) {     queue<int> q;     memset(d, -1, sizeof(d));     q.push(a);     d[a] = 0;     while (!q.empty()) {       int st = q.front();       q.pop();       for (int i = 2; i <= k; i++) {         if (st % i == 0) continue;         int tmp = st - st % i;         if (tmp < 0) tmp += lcm;         if (d[tmp] <= 0) {           d[tmp] = d[st] + 1;           q.push(tmp);         }       }       int tmp = st - 1;       if (tmp < 0) tmp += lcm;       if (d[tmp] <= 0) {         d[tmp] = d[st] + 1;         q.push(tmp);       }     }     return d[target];   }   int main(void) {     cin >> a >> b >> k;     lcm = 1;     for (int i = 2; i <= k; i++) lcm = lcm / gcd(lcm, i) * i;     long long ans = 0;     if (a / lcm == b / lcm) {       if (a % lcm != b % lcm) ans = bfs(a % lcm, b % lcm);     } else {       if (a % lcm) ans += bfs(a % lcm, 0);       if (b % lcm) ans += bfs(0, b % lcm);       ans += (a / lcm - b / lcm - 1) * bfs(0, 0);     }     cout << ans << endl;   }   