Cod sursa(job #1992090)

Utilizator alex2704Pirvuceanu Alexandru alex2704 Data 19 iunie 2017 13:33:46
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
int t,i,j,n;
double power(unsigned long long x,unsigned long long y)
{
    int res = 1;

    while (y > 0)
    {
        if (y & 1)
            res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}
int main()
{
    f>>t;
    for(i=1;i<=t;i++)
    {
        f>>n;
        long long s=0;
        for(j=1;j<=n;j++)
            s=s+power(j,j);
    g<<s%10<<'\n';
    }
}