Cod sursa(job #1408603)

Utilizator stefan_gheorgheGheorghe Stefan stefan_gheorghe Data 30 martie 2015 09:36:53
Problema Cifra Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.85 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
int t,j,i,s,p,c,x,y;
long long a[30000];
int main()
{
    f>>t;
    for (j=1; j<=t; j++)
    {
        f>>a[j];
    }
    for (j=1; j<=t; j++)
    {
        s=0;
        y=a[j]%100;
        for (i=1; i<=y; i++)
        {
            c=i%4;
            x=i%10;
            if (c==0)
            {
                p=(x*x*x*x)%10;
                s=(s+p)%10;
            }
            if (c==1)
            {
                s=(s+x)%10;
            }
            if (c==2)
            {
                p=(x*x)%10;
                s=(s+p)%10;
            }
            if (c==3)
            {
                p=(x*x*x)%10;
                s=(s+p)%10;
            }
        }
        g<<s<<'\n';
    }
    return 0;
}