Cod sursa(job #1075591)
Utilizator | Data | 9 ianuarie 2014 11:21:14 | |
---|---|---|---|
Problema | GFact | Scor | 15 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <fstream>
using namespace std;
ifstream f("gfact.in");
ofstream g("gfact.out");
int putere (int x, int p){
int s=0;
while(x!=0){
s=s+x/p;
x=x/p;
}
return s;
}
int main()
{
int q,p,i=0,pas=1<<30;
f>>p>>q;
while(pas!=0){
if(putere(i+pas,p)<q)
i+=pas;
pas/=2;
}
g<<i+1;
return 0;
}