Cod sursa(job #2531958)
Utilizator | Florea Deborah dflr | Data | 26 ianuarie 2020 22:11:42 |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream f("cifra.in");
ofstream g("cifra.out");
int t,i,j,s,k,aux;
f>>t; char v[t];
for(i=0;i<t;i++)
f>>v[i];
for(i=0;i<t;i++)
{
s=0;
for(j=1;j<=v[i]-'0';j++)
{
aux=j;
for(k=1;k<=j-1;k++)
aux=(aux*j)%10;
s+=aux;
}
//s+=long(pow(j,j))%10;
g<<s%10<<"\n";
}
return 0;
}