Mai intai trebuie sa te autentifici.
Cod sursa(job #2009159)
Utilizator | Data | 8 august 2017 18:31:47 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.71 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("cifra.in");
ofstream fout("cifra.out");
int T, ucv[11][5], dpre[30010], x;
void pre_uc()
{
for(int i=0; i<=9; i++)
{
ucv[i][1] = i;
for(int j=2; j<=4; j++){
ucv[i][j] = (ucv[i][j-1]*i) % 10;
}
ucv[i][0] = ucv[i][4];
}
}
int uc(int a)
{
int d = a%10, ex=a%4;
return ucv[d][ex];
}
void pre_proc()
{
dpre[1] = 1;
for(int i=2; i<=30001; i++)
dpre[i] = (dpre[i-1] + uc(i)) % 10;
}
int main()
{
fin >> T;
pre_uc();
pre_proc();
for(int i=1; i<=T; i++)
{
fin >> x;
fout << dpre[x]<< '\n';
}
return 0;
}