Cod sursa(job #2470274)

Utilizator rchiteaIRCHIT rchitea Data 8 octombrie 2019 22:41:07
Problema Factorial Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream fin ("fact.in");
ofstream fout ("fact.out");

int main()
{
    int x, sol=0;
    fin >> x;
    if(x==0)
    {
        fout << 1;
        return 0;
    }
    int ver=25, c=1;
    while(x)
    {
        x--;
        sol+=5;
        if(ver==sol)
            x-=c, ver*=5, c++;
    }
    fout << sol;

    return 0;
}