Cod sursa(job #1715025)

Utilizator adystar00Bunea Andrei adystar00 Data 9 iunie 2016 21:42:27
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    ifstream fin ("fact.in");
    ofstream fout ("fact.out");
    int n,ans,ct,nr,ad=0,pt=5,m=25;
    long long p;
    fin>>p;
    if(p==0)
        fout<<"1 ";
    else
    {
        //cout<<"Vf";
        nr=1;
        ans=5;
        ct=1;
        while(ct<p)
        {
            ans+=5;
            if(ans==m){
                ad++;
                m*=5;
                ct=ct+ad;
            }
            ct++;
        }
        fout<<ans;
    }
    return 0;
}