Pagini recente » Cod sursa (job #3287406) | Cod sursa (job #1420404) | Cod sursa (job #1402135) | Cod sursa (job #2935776) | Cod sursa (job #2914228)
// Online C Compiler - Build, Compile and Run your C programs online in your favorite browser
#include<iostream>
#include<fstream>
#include<cmath>
int main()
{
std::ifstream f("fact.in");
unsigned int p;
f>>p;
f.close();
unsigned long int fact = 1;
unsigned long int ctr = 2;
while(fact%(unsigned long int)pow(10,p) != 0)
{
fact = (fact * ctr%(unsigned long int)pow(10,p+1))%(unsigned long int)pow(10,p+1);
ctr++;
}
std::ofstream of("fact.out");
if(fact%(unsigned long int)pow(10,p+1)!=0)
{
of<<ctr-1;
}
else
{
of<<-1;
}
std::cout<<ctr-1<<std::endl;
std::cout<<fact;
of.close();
return 0;
}