Cod sursa(job #1561834)
Utilizator | Data | 4 ianuarie 2016 16:41:16 | |
---|---|---|---|
Problema | Factorial | Scor | 35 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int p,n,x,s,k;
int main()
{
f>>p;
if (p==0) g<<1;
else{
n=p*5;
x=n/5;
while(x)
{
s+=x;x/=5;
}
if (s==p) g<<n;
else {
while (s>p) {
s=0;
x=n/5;
while(x)
{
s+=x;x/=5;
}
n-=5; }
g<<n+5;
}}
return 0;
}