Cod sursa(job #1830758)

Utilizator xRoALexBirtoiu Alexandru xRoALex Data 17 decembrie 2016 07:43:10
Problema GFact Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <cstdio>

using namespace std;

FILE *f=fopen("gfact.in","r");
FILE *g=fopen("gfact.out","w");

int baza,putere;

int cifre(int x)
 {
   int s=0;
   while(x)
   {
       x=x/baza;
       s+=x;
   }
   return s;
 }

int rez1()
{
    int pas=1<<30,r=0;
    while(pas!=0)
    {
        if(cifre(r+pas)<putere)
            r+=pas;
         pas/=2;
    }
    return r;
}

int main()
{
    fscanf(f,"%d%d",&baza,&putere);
    fprintf(g,"%d",rez1()+1);
    return 0;
}