Cod sursa(job #2617703)

Utilizator pascustefanPascu Stefan Liviu pascustefan Data 22 mai 2020 17:15:09
Problema Factorial Scor 15
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.34 kb
#include <iostream>
#include <fstream>

using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int n, s, c1, c2, c3, c4, c5, c6, c7, c8;

int main()
{
    f>>n;
    c2 = 0;
    c3 = 0;
    c4 = 0;
    c5 = 0;
    c6 = 0;
    c7 = 0;
    c8 = 0;
    if(n == 0)
        g<<1;
    else {
        s = 5;
        n--;
        c1 = 1;
        while(n > 0) {
            s = s + 5;
            n--;
            c1++;
            if(c1 == 5) {
                n--;
                c2++;
                c1 = 0;
            }
            if(c2 == 5) {
                n--;
                c3++;
                c2 = 0;
            }
            if(c3 == 5) {
                n--;
                c4++;
                c3 = 0;
            }
            if(c4 == 5) {
                n--;
                c5++;
                c4 = 0;
            }
            if(c5 == 5) {
                n--;
                c6++;
                c5 = 0;
            }
            if(c6 == 5) {
                n--;
                c7++;
                c6 = 0;
            }
            if(c7 == 5) {
                n--;
                c8++;
                c7 = 0;
            }
            if(c8 == 5) {
                n--;
                c8 = 0;
            }
        }
    }
    g<<s;
    return 0;
}