Cod sursa(job #2288736)
Utilizator | Data | 23 noiembrie 2018 20:07:09 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.4 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin("fact.in");
ofstream fout("fact.out");
int p, n = 1, k, np = 0, nn = 0;
cin >> p;
for (int i = 1; i <= p; i++)
n *= i;
k = n;
while (k != 0)
{
nn++;
k /= 10;
}
while (p != 0)
{
np++;
p /= 10;
}
if (nn == np) cout << n;
else cout << -1;
system("pause");
return 0;
}