Cod sursa(job #990117)

Utilizator piticutzu15Covaciu Andrei piticutzu15 Data 27 august 2013 14:51:49
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <fstream>
#include <math.h>
using namespace std;
int main()
{
    int t,n,s,j,x,i;
    ifstream f ("cifra.in");
    ofstream g ("cifra.out");
    f>>t;
    for(i=1;i<=t;i++)
    {
        f>>n;
        j=1;
        s=0;
        x=1;
        while(j<=n)
        {
            s=s+powl(j,x);
            j++;
            x++;
        }
        g<<s%10<<endl;
    }
    f.close();
    g.close();
    return 0;
}