Cod sursa(job #2282744)

Utilizator 2016Teo@Balan 2016 Data 14 noiembrie 2018 14:22:43
Problema GFact Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.9 kb
#include <bits/stdc++.h>
using namespace std;
ifstream in("gfact.in");
ofstream out("gfact.out");
int v[11],f[11],c,q;
long long putere(long long n, int p) {
    long long r = 0;
    while (n >= p) {
        r += n / p;
        n /= p;
    }
    return r;
}

bool divfact(long long n) {
    for (int i = 0; i < c; i++) {
        if (putere(n, v[i]) < f[i] * q) {
            return false;
        }
    }
    return true;
}
long long cautb() {
    long long r = 0, pas = 1LL << 45;
    while (pas != 0) {
        if (!divfact(r + pas)) {
            r += pas;
        }
        pas /= 2;
    }
    r++;
    return r;
}
int main() {
    int p,i,j,a,d=2;
    in>>p>>q;
    while(d*d<=p) {
        if(!p%d) {
            v[c]=d;
            while(!p/d) {
                f[c]++;
                p/=d;
            }
            c++;
        }
        d++;
    }

    return 0;
}