Cod sursa(job #895020)

Utilizator AnduuFMI Alexandru Banu Anduu Data 27 februarie 2013 09:19:40
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
    int T,i,x,s,p,c,j;
    ifstream f("cifra.in");
    ofstream g("cifra.out");
    f>>T;
    for (i=1;i<=T;i++)
    {
        f>>x;
        s=1;
        for (j=2;j<=x;j++)
        {
            c=1;
            p=j%10;
            while (c!=j)
            {
                p=(p*j)%10;
                c++;
            }
            s+=p;
        }
        g<<s%10<<endl;
    }
    f.close();
    g.close();
    return 0;
}