Cod sursa(job #1408571)

Utilizator stefan_gheorgheGheorghe Stefan stefan_gheorghe Data 30 martie 2015 09:15:50
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.82 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
int t,c,i,j,x,p,s,a[10000];
int main()
{
    f>>t;
    for (j=1; j<=t; j++)
    {
        f>>a[j];
    }
    for (j=1; j<=t; j++)
    {
        s=0;
        for (i=1; i<=a[j]; 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;
}