Cod sursa(job #1066682)

Utilizator petretiberiu46Petre Tiberiu petretiberiu46 Data 25 decembrie 2013 13:58:58
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <iostream>
#include <fstream>

using namespace std;
int t, n, s, p, cp;

int pow(int n)
{
    p = n;
    int i = 1;
    while(i!=n)
    {
        p = p * n;
        i = i+1;
    }
    return p;
}

int main()
{
    fstream fin("cifra.in", ios::in);
    fstream fout("cifra.out", ios::out);

    fin>>t;
    for(int i = 1; i<=t; i++)
    {
        fin>>n;
        s = 0;
        for(int j = 1; j<=n; j++)
        {
            s = s + pow(j);
        }
        fout<<s%10<<endl;
    }

}