Cod sursa(job #2072009)
Utilizator | Data | 21 noiembrie 2017 12:05:03 | |
---|---|---|---|
Problema | GFact | Scor | 15 |
Compilator | c | Status | done |
Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <stdio.h>
#include <stdlib.h>
int check(int x,int p)
{
if(x!=0)
return x/p+check(x/p,p);
return 0;
}
int main()
{
int q,t,r,p;
FILE*fi,*fo;
fi=fopen("gfact.in","r");
fo=fopen("gfact.out","w");
fscanf(fi,"%d%d",&q,&t);
r=0;
p=1<<30;
while(p!=0)
{
if(check(r+p,q)<t)
r+=p;
p/=2;
}
fprintf(fo,"%d",r+1);
fclose(fi);
fclose(fo);
return 0;
}