Cod sursa(job #1793926)

Utilizator shantih1Alex S Hill shantih1 Data 31 octombrie 2016 17:47:03
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <iostream>
#include <cmath>
#include <fstream>
using namespace std;

ifstream fin("fact.in");
ofstream fout("fact.out");

int n, k, i, j, s=1, p;
long long x, nf;
int main() {
    
    fin >> p;
    
    x = pow ( 10 , p );
    fout << x << " ";
    nf = 1;
    n = 1;
    
    if ( p > 0 )
    {
        while ( nf % x != 0 )
        {
        
            nf = nf * n;
            nf = nf % x;
            n = n + 1;
            k = k + 1;
        }
        
        fout << k << "\n";
    }
    
    else fout << 1 << "\n";
    
    return 0;
}