Cod sursa(job #3144997)
Utilizator | Data | 11 august 2023 18:44:26 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
int main()
{int T, N;
f>>T;
for(int i=1; i<=T; i++)
{ f>>N;
long long cifra=0;
for(int j=1; j<=N; j++)
{ int pw=1;
for(int k=1; k<=j; k++)
{
pw=(pw*j)%10;
}
cifra=(cifra+pw)%10;
}
g<<cifra<<'\n';
}
return 0;
}