Cod sursa(job #17480)
Utilizator | Data | 15 februarie 2007 23:32:02 | |
---|---|---|---|
Problema | Factorial | Scor | 15 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include<iostream.h>
#include<fstream.h>
#include<math.h>
long n=1,p,i=1,s=0,ok=0;
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
while(i<=p)
{s=s+5;
if(i%5==0)
{i++;
if(i==p)
{g<<s;ok=1;}
}
i++;
}
if(s>pow(10,8))
g<<"-1";
else
if(s==0)
g<<n;
else
if(ok==0)
g<<s;
f.close();g.close();
return 0;
}