Cod sursa(job #1185503)

Utilizator ChrystianSanduSandu Cristian ChrystianSandu Data 15 mai 2014 21:13:47
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <iostream>
#include <fstream>

using namespace std;

int main()
{int p,k,i,s,n,x,j,g;
    ifstream fin ("cifra.in");
    ofstream fout ("cifra.out");
    fin >> n;
    for (i=1; i<=n; i++)
    {
        s = 0;
        fin >> k;
        x = 1;
        for (p=1; p<=k; p++)
            {
                g = 1;

                for (j=1; j<=p; j++)
                {
                    g = g*x;
                }
                s = s + g%10;
                s = s%10;
                x++;
            }
    fout << s << "\n";
    }
    return 0;
}