Cod sursa(job #1324851)
| Utilizator | Data | 22 ianuarie 2015 20:58:44 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int n,i,j,p;
int cautbin(long long a,long long b)
{
if(a>b)
return -1;
int m=(a/5+b/5)/2;
m*=5;
int pa,pb,pm;
pa=a/5+(a/5)/5;
pb=b/5+(b/5)/5;
pm=m/5+(m/5)/5;
if(pm>n)
return cautbin(a,m-5);
else
if(pm<n)
return cautbin(m+5,b);
else
return m;
}
int main()
{
f>>n;
if(n==0)
g<<"1"<<'\n';
else
{
g<<cautbin(0,n*5)<<'\n';
}
return 0;
}
