Cod sursa(job #1077101)

Utilizator warrior98Cheregi Alexandru warrior98 Data 10 ianuarie 2014 21:39:45
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include<iostream>
#include<cmath>
#include<fstream>

using namespace std;

ifstream fin("cifra.in");
ofstream fout("cifra.out");

int main()
{
    unsigned int t; fin >> t;
    unsigned int suma = 0;
    unsigned int n;
    unsigned int putere;

    for (unsigned int i = 0; i < t; i++) {
        fin >> n;

        for (unsigned int k = 1; k <= n; k++) {
            putere = pow(k, k);
            suma += putere%10;
        }

        fout << suma%10 << endl;

        suma = 0;
    }

    fin.close();
    fout.close();
}