Cod sursa(job #2159678)

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


int i,t,u,suma;
int main()
{

    f>>t;
    while (t!=0)
    {
       f>>u;
       suma=(u*(u+1)*(2*u+1))/6;
       g<<suma%10;
    }

    return 0;
}




// 0 0
// 1 1
// 2 4
// 3 9
// 4 6
// 5 5
// 6 6
// 7 9
// 8 4
// 9 1
// n(n+1)(2n+1)/6