Cod sursa(job #2159682)

Utilizator VladP02Popescu Vlad VladP02 Data 11 martie 2018 09:23:57
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
    #include <iostream>
    #include <fstream>
    #include <iostream>
    #include <iomanip>
using namespace std;
    ifstream f("cifra.in");
    ofstream g("cifra.out");

int suma(int n)
    {int i;
        i=(n*(n+1)*(2*n+1))/6;
        return i;
    }




int k,i,t,u,a[100];
int main()
{
    a[0]=0;a[1]=1;a[2]=4;a[3]=9;a[4]=6;a[5]=5;a[6]=a[4];a[7]=a[3];a[8]=a[2];a[9]=a[1];


    f>>t;
    while (t!=0)
    {
        f>>u;
        g<<suma(u)%10<<endl;
        t--;
    }

    return 0;
}




// 0 0
// 1 1
// 2 4
// 3 9
// 4 6
// 5 5
// 6 6
// 7 9
// 8 4
// 9 1