Cod sursa(job #932088)

Utilizator RauliKMarian Raul RauliK Data 28 martie 2013 18:19:29
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <fstream>
#include <cmath>
using namespace std;
int main()
{
    int t, n, i, k;
    double j;
    ifstream fin("cifra.in");
    ofstream fout("cifra.out");
    fin >> t;
    if ( t < 1 || t > 30000 )
    {
         fout << "T trebuie sa fie cuprins in intervalul [1,30000]";
    }
    else
    {
        for ( i = 1; i <= t; i++ )
        {
            k = 0;
            fin >> n;
            for ( j = 1; j <= n; j++ )
            {
                k = pow(j,j) + k;
            }
            if ( k > 9 )
            {
                 fout << k % 10 << endl;
            }
            else
            {
                fout << k << endl;
            }
        }
    }
    fin.close();
    fout.close();
    return 0;
}