Cod sursa(job #1573776)

Utilizator GeorgeAAndrei George Matei GeorgeA Data 19 ianuarie 2016 22:16:03
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <fstream>
#include <cmath>

using namespace std;
ifstream cin ("cifra.in");
ofstream cout ("cifra.out");

int power(int a, int b)
{
    if (b==1) return a;
    else return a*power(a,b-1);
}

int main()
{
    int n,s,i,v[30000],t,j;
    cin>>t;

    for (j=1;j<=t;j++)
    {
        cin>>v[j];
        s=0;
        for(i=1;i<=j;i++)
        {
        s=s+power(v[i],v[i]);
        }
         cout<<s%10<<endl;
    }
    return 0;
}