Cod sursa(job #1470714)
Utilizator | Data | 11 august 2015 22:44:18 | |
---|---|---|---|
Problema | GFact | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.6 kb |
#include<cstdio>
#define INF ((1 << 31) - 1)
using namespace std;
int A, B, st, dr, nr, div, DIV;
int main()
{
freopen("gfact.in","r",stdin);
freopen("gfact.out","w",stdout);
scanf("%d%d", &A, &B);
st = 1;
dr = INF;
while (st < dr)
{
div = (st + dr)/2;
DIV = div;
nr = 0;
while (DIV)
nr += DIV/A, DIV /=A;
if (nr < B)
st = div + 1;
else
dr = div;
}
printf("%d", st);
}