Cod sursa(job #48991)

Utilizator the_dragon_of_rockTzogorean Alex the_dragon_of_rock Data 5 aprilie 2007 11:17:05
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.71 kb
#include<fstream.h>
long long int n,p;

int main()
{
    ifstream in("fact.in"); 
    in>>p;
    n=625*(p/156);
    p=p-156*(p/156);
    long long int m;
    while(p>0)
        {
            n+=5;
            m=n;
            while(m%5==0)
                {
                    m=m/5;
                    p--;
                }
        }
    /*long long int t=0,m;
    while(p>4)
        {
            m=p;
            while(m%5==0)
                {
                    m=m/5;
                    t++;
                }
            p-=5;
        }*/
    
    
    ofstream out("fact.out");
    if (p==0)
        out<<n;
    if (p<0)
        out<<-1;
    //out<<t;
    
    return 0;
}