Cod sursa(job #1198547)

Utilizator teodor440Teodor Tonghioiu teodor440 Data 16 iunie 2014 09:43:50
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.36 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream f("fact.in");
ofstream g("fact.out");

int main()
{
    long long p,x=1;
    f>>p;
    while(p>0){
        if(x%5==0&&x){
            p-=x/5+1;
        }
        else p--;
        x++;
    }
    if(!p){
        x*=5;
        g<<x-5;
    }
    else g<<-1;

    return 0;
}