Pagini recente » Cod sursa (job #682488) | Cod sursa (job #1950197) | Cod sursa (job #1630341) | Cod sursa (job #2684821) | Cod sursa (job #2914197)
// 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");
int p;
f>>p;
f.close();
long unsigned int fact = 1;
long unsigned int ctr = 2;
while(fact%(long unsigned int)pow(10,p) != 0)
{
fact = (fact * ctr%(long unsigned int)pow(10,p+1))%(long unsigned int)pow(10,p+1);
ctr++;
}
std::ofstream of("fact.out");
if(fact%(long unsigned int)pow(10,p+1)!=0)
{
of<<ctr-1;
}
else
{
of<<-1;
}
of.close();
return 0;
}