Cod sursa(job #1303134)

Utilizator Andreicm12Matraguna Andrei Andreicm12 Data 27 decembrie 2014 17:32:22
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include <fstream>
#include <math.h>

using namespace std;

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