Pagini recente » Cod sursa (job #162169) | Cod sursa (job #3248891) | Cod sursa (job #8546) | Cod sursa (job #2068621) | Cod sursa (job #2068148)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("gfact.in");
ofstream g("gfact.out");
int v[200], d[300], nd;
long long putere ( long long n, int al) {
long long s = 0;
while ( n >= al ) {
s += (n/=al);
}
return s;
}
bool sepoate( long long n ) {
for ( int i = 0; i < nd; i++ ) {
if ( putere(n, v[i]) < d[i] ) {
return false;
}
}
return true;
}
long long cb() {
long long r = 0, pas = 1LL << 60;
while ( pas != 0 ) {
if ( !sepoate(r+pas) )
r += pas;
pas /= 2;
}
return r+1;
}
int main()
{
int n, fact;
f >> n >> fact;
int hb = 2;
while ( hb * hb <= n ) {
if ( n % hb == 0 ) {
v[++nd] = hb;
while ( n % hb == 0 ) {
n /= hb;
d[nd]++;
}
d[nd] *= fact;
}
}
if (n != 1) {
v[++nd] = n;
d[nd] = fact;
}
f.close();
g.close();
return 0;
}