Cod sursa(job #1700192)
| Utilizator | Data | 9 mai 2016 19:41:29 | |
|---|---|---|---|
| Problema | GFact | Scor | 15 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("gfact.in");
ofstream out("gfact.out");
int p, q;
int nr( int x )
{
int s = 0;
while( x >= p )
{
s+=x/p;
x/=p;
}
return s;
}
int cautare()
{
int pas = 1 << 30;
int i = 0, x;
while( pas != 0 )
{
x = nr(i+pas);
if ( x < q )
{
i+=pas;
}
pas/=2;
}
return i;
}
int main()
{
in >> p >> q;
out << cautare()+1;
return 0;
}
