Cod sursa(job #1983851)

Utilizator AlexandruPaulSirbu Alex AlexandruPaul Data 22 mai 2017 17:03:51
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.01 kb
#include <iostream>
#include <fstream>

using namespace std;
ifstream f("fact.in");
ofstream l("fact.out");
int n,p,nr0,j,r,i,y,k,h,d,v[10000],nr,gasit;

int main()
{
    f>>p;
    gasit=0;
    if (p==0)
    {
        cout<<1;
        gasit=1;
    }
    if (p==1)
    {
        cout<<5;
        gasit=1;
    }
    i=5;
    while (i<=10000000000 and gasit==0)
    {
        n=i;
        for (j=5; j<=n; j=j+5)
        {
            y=1;
            while (r!=0)
            {
                r=j/5;
                k=j%5;
                h++;
                v[h]=k;
            }
            for (i=h; i>0; i--)
            {
                y=y*10+v[i];
            }
            nr=0;
            d=0;
            while (d==0)
            {
                d=y%10;
                nr++;
                y=y/10;
            }
            nr0=nr0+nr;
        }
        if (p==nr0)
        {
            cout<<n;
            gasit=1;
        }
        i++;
    }
    return 0;
}