Cod sursa(job #869853)
| Utilizator | Data | 2 februarie 2013 14:10:53 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.69 kb |
#include <fstream>
#include <iostream>
using namespace std;
int main ( )
{
int P;
ifstream fin ("fact.in");
fin >> P;
long int x = 1;
int nrz = 0;
int N;
if ( P == 0 )
N = 1;
else
for ( int i = 1 ; i < 100000000 ; ++ i )
{
x = x * i;
cout << i << " " << x << "\n";
if ( x % 10 == 0 )
{
++ nrz;
x /= 10;
}
if ( nrz == P )
{
N = i;
break;
}
}
ofstream fout ("fact.out");
fout << N;
fin.close ();
fout.close ();
return 0;
}
