Cod sursa(job #187951)

Utilizator cotofanaCotofana Cristian cotofana Data 5 mai 2008 21:21:51
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.77 kb
#include <stdio.h>   
  
long n;   
long nr;   
  
void cit()   
{   
        FILE *f=fopen("fact.in", "r");   
        fscanf(f, "%ld", &n);   
        fclose(f);   
}   
  
void tip()   
{   
        FILE *f=fopen("fact.out", "w");   
        fprintf(f, "%ld\n", nr);   
        fclose(f);   
}   
  
void fct()   
{   
        int i=0,t;   
        while (nr<n)   
        {   
                i+=5;   
                nr+=5;   
                if (nr<n)   
                {   
                t=i;   
                do  
                {   
  
                        if (t%5==0) t/=5;   
                        nr++;   
                } while (t%5==0);   
                }   
                else  
                {   
                        i-=nr-n;   
                }   
        }   
        nr=5*i;   
}   
  
int main()   
{   
        cit();   
        fct();   
        tip();   
        return 0;   
}  
#include <stdio.h>

long n;
long nr;

void cit()
{
        FILE *f=fopen("fact.in", "r");
        fscanf(f, "%ld", &n);
        fclose(f);
}

void tip()
{
        FILE *f=fopen("fact.out", "w");
        fprintf(f, "%ld\n", nr);
        fclose(f);
}

void fct()
{
        int i=0,t;
        while (nr<n)
        {
                i+=5;
                nr+=5;
                if (nr<n)
                {
                t=i;
                do
                {

                        if (t%5==0) t/=5;
                        nr++;
                } while (t%5==0);
                }
                else
                {
                        i-=nr-n;
                }
        }
        nr=5*i;
}

int main()
{
        cit();
        fct();
        tip();
        return 0;
}