Cod sursa(job #2999301)

Utilizator razvanigarazvaniga stanos razvaniga Data 10 martie 2023 20:01:14
Problema Factorial Scor 0
Compilator cpp-32 Status done
Runda Arhiva de probleme Marime 0.53 kb
#include <iostream>
#include <fstream>

using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");

long long int n,p=6;
bool ok=true;

long long int v[7];

bool verif(int x){
    while(x>30) x-=31;
    for(int i=1;i<=6;i++) if(v[i]==x) ok=false;
}

int main()
{
    v[1]=5;
    v[2]=11;
    v[3]=17;
    v[4]=23;
    v[5]=29;
    v[6]=30;
    fin>>n;
    if(!n)n++;
    verif(n);
    while(n/p>0 && ok){
        n-=(int)(n/p);
        p*=6;
    }
    if(ok) fout<<n*5;
    else fout<<"-1";
}