Cod sursa(job #3253900)
Utilizator | Data | 5 noiembrie 2024 11:22:42 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.38 kb |
//
// main.cpp
// fact
//
// Created by Andrada Minca on 05.11.2024.
//
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int p,s,i;
int main() {
fin>>p;
int k=1,kk=5;
for(i=1;i<=p;i++)
{
s+=5;
if(i%kk==0){i+=k;k++;kk*=5;}
}
if(s==0)fout<<1;
else if(i==p+1) fout<<s;
else fout<<-1;
return 0;
}