Cod sursa(job #1252985)

Utilizator dcutitoiuCutitoiu Adrian-Nicolae dcutitoiu Data 31 octombrie 2014 17:45:27
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
#include<fstream>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
float Power(float Base, int Power)
{
        float Return = 1;
        if ( Power > 0)
               for (int n = 0; n < Power; n++)
                      Return *= Base;
        else
               for (int n = 0; n > Power; n--)
                      Return /= Base;
        return Return;
}
int main()
{
    int T,s,j,i,k,p;
    long int N;
    f>>T;
    while(f>>N)
    {
        f>>N;
        s=0;
        for(i=1;i<=N;i++)
        {
            s=s+Power(i,i);
        }
        g<<s%10<<endl;
    }
    return 0;
}