Comments
0

I really beg you all that please take away the allegations because I swear I didn’t cheat and please some how remorse the messages it will damage me a lot so I beg u codeforces and I will solve one problem out of the 6

This is some text.

// this is code
void inc(int pos, int d) {
    for (; pos < n; pos |= pos + 1)
        f[pos] += d;
}

The rest of the text.

include <bits/stdc++.h>

using namespace std;

using int64 = long long;

// Generate all divisors of n from its prime factorization void genDivisors(const vector<pair<int, int>>& pf, int idx, int64 cur, vector& divs) { if (idx == (int)pf.size()) { divs.push_back(cur); return; } int p = pf[idx].first, e = pf[idx].second; for (int i = 0; i <= e; ++i) { genDivisors(pf, idx + 1, cur, divs); cur *= p; } }

// BFS on the "dividing" graph: from n down to 1 int bfsDivide(int64 n, int k) { if (n == 1) return 0;

vector<pair<int, int>> pf;
int64 m = n;
for (int p = 2; (int64)p * p <= m; ++p) {
    if (m % p == 0) {
        int cnt = 0;
        while (m % p == 0) {
            m /= p;
            ++cnt;
        }
        pf.emplace_back(p, cnt);
    }
}
if (m > 1) pf.emplace_back((int)m, 1);

vector<int64> divs;
genDivisors(pf, 0, 1, divs);
sort(divs.begin(), divs.end());

int D = divs.size();
unordered_map<int64, int> id;
id.reserve(D * 2);
for (int i = 0; i < D; ++i) id[divs[i]] = i;

vector<int> dist(D, -1);
deque<int> q;

int start = id[n];
dist[start] = 0;
q.push_back(start);

while (!q.empty()) {
    int u_i = q.front();
    q.pop_front();
    int64 u = divs[u_i];
    int d = dist[u_i];

    if (u == 1) return d;

    for (int i = 0; i < D; ++i) {
        int64 a = divs[i];
        if (a < 2) continue;
        if (a > k) break;
        if (u % a != 0) continue;

        int64 v = u / a;
        int v_i = id[v];
        if (dist[v_i] == -1) {
            dist[v_i] = d + 1;
            q.push_back(v_i);
        }
    }
}
return -1;

}

// BFS on the "multiplying" graph: from 1 up to n int bfsMultiply(int64 n, int k) { if (n == 1) return 0;

vector<pair<int, int>> pf;
int64 m = n;
for (int p = 2; (int64)p * p <= m; ++p) {
    if (m % p == 0) {
        int cnt = 0;
        while (m % p == 0) {
            m /= p;
            ++cnt;
        }
        pf.emplace_back(p, cnt);
    }
}
if (m > 1) pf.emplace_back((int)m, 1);

vector<int64> divs;
genDivisors(pf, 0, 1, divs);
sort(divs.begin(), divs.end());

int D = divs.size();
unordered_map<int64, int> id;
id.reserve(D * 2);
for (int i = 0; i < D; ++i) id[divs[i]] = i;

vector<int> dist(D, -1);
deque<int> q;

int start = id[1];
dist[start] = 0;
q.push_back(start);

while (!q.empty()) {
    int u_i = q.front();
    q.pop_front();
    int64 u = divs[u_i];
    int d = dist[u_i];

    if (u == n) return d;

    for (int i = 0; i < D; ++i) {
        int64 a = divs[i];
        if (a < 2) continue;
        if (a > k) break;
        int64 v = u * a;
        if (v > n) break;
        if (n % v != 0) continue;

        int v_i = id[v];
        if (dist[v_i] == -1) {
            dist[v_i] = d + 1;
            q.push_back(v_i);
        }
    }
}
return -1;

}

int main() { ios::sync_with_stdio(false); cin.tie(nullptr);

int t;
cin >> t;
while (t--) {
    int64 x, y;
    int k;
    cin >> x >> y >> k;

    if (k == 1) {
        cout << (x == y ? 0 : -1) << '\n';
        continue;
    }

    int64 g = __gcd(x, y);
    int64 d1 = x / g, d2 = y / g;

    int ops1 = bfsDivide(d1, k);
    if (ops1 < 0) {
        cout << -1 << '\n';
        continue;
    }

    int ops2 = bfsMultiply(d2, k);
    if (ops2 < 0) {
        cout << -1 << '\n';
        continue;
    }

    cout << (ops1 + ops2) << '\n';
}

return 0;

}

0

Hi dear codeforces I have conclusive evidence well first of all I did not cheat and and I did not leak any kind of code if u want the truth I will upload my code right of all the 6 questions I solved in which one of them got hacked__