Cod sursa(job #1274107)

Utilizator Andreicm12Matraguna Andrei Andreicm12 Data 23 noiembrie 2014 12:35:14
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <fstream>
#include <math.h>

using namespace std;

int main()
{
    ifstream f("cifra.in");
    ofstream g("cifra.out");
    int t,x,s,n,c;
    f>>t;
    while(t>0)
        {f>>n;
        x=1;
        s=0;
        while(x<=n)
        {
            c=pow(x,x);
            s=s+(c%10);
            x=x+1;
        }
        g<<s%10<<"\n";
        t=t-1;
        }
    return 0;
}