Mai intai trebuie sa te autentifici.
Cod sursa(job #921114)
| Utilizator | Data | 20 martie 2013 19:47:21 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <iostream>
#include <fstream>
using namespace std;
int pow(int a, int b){
int r=1;
while(b>0){
r = r * a;
b--;
}
return r;
}
int main(){
int P;
ifstream f("fact.in");
f>>P;
f.close();
P=P*4;
bool ok=true;
int k=2;
while(ok){
int putere = pow(5,k);
double rez = P * putere / (putere-1);
if(rez % 1 == 0)
ok=false;
else k++;
}
ofstream g("fact.out");
g<<rez;
g.close();
return 0;
}
