Cod sursa(job #921162)
Utilizator | Data | 20 martie 2013 20:16:02 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.61 kb |
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int power(int a, int b){
int rez=1;
while(b>0){
rez=rez*a;
b--;
}
return rez;
}
int main(){
ifstream f("fact.in");
int P, nr=0;
f>>P;
f.close();
P=4*P;
bool ok=true;
int k=2;
while(ok){
if(floor(P/(power(5,k-2)-1)) == P/(power(5,k-2)-1))
ok=false;
else k++;
}
nr = P/(power(5,k-2)-1) * power(5,k);
ofstream g("fact.out");
g<<nr;
g.close();
return 0;
}