Cod sursa(job #1413273)

Utilizator mist.moonDenisa Gherghel mist.moon Data 1 aprilie 2015 19:31:07
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <iostream>
#include <stdio.h>

using namespace std;
int p;
int aparitii (int n)
{
    int ap=0;
    while(n%5==0) { ap++; n=n/10; }
    return ap;
}
int main(int argc, char *argv[])
{
    freopen("fact.in","r",stdin);
    freopen("fact.out","w",stdout);
    scanf("%d", &p);

    if(p==0) { printf("%d \n", 1); return 0; }
    else
    {
         int nr=1, init=5;
         while(nr<p)
         {
                    init=init+5;
                    nr=nr+aparitii(init);
                    }
         if(nr==p) printf("%d \n", init);
         else printf("%d \n", -1);
         return 0;
     }


}