Cod sursa(job #1438427)
Utilizator | Data | 19 mai 2015 22:18:50 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.63 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("fact.in");
ofstream g ("fact.out");
int valid(int x)
{
int d;
for(d=2;;d++)
{
if(x%d)
{
while(x%d==0)
x=x/d;
if(x==1)
return 1;
else
return 0;
}
}
}
int main()
{
int n,i,c,cop,x,k;
f>>n;
if(n==0)
g<<0;
else
if(valid(n)==1)
g<<-1;
else
{
c=n*5;
x=25;
while(x<c)
{
x+=25;
c-=5;
}
g<<c;
}
return 0;
}