Pagini recente » preONI 2008 - Runda Finala, Regulament | Cod sursa (job #3278709) | Hashtag | Rating Balescu Ovidiu-Gheorghe (Balescu_Ovidiu) | Cod sursa (job #1419101)
#include <fstream>
#include <cstring>
#define DIM 100010
using namespace std;
ifstream fin ("cifra.in" );
ofstream fout("cifra.out");
int N, M, i, j, k, ok, minim, V[DIM], x;
char S[DIM];int T, nr;
void TestExpert(){
for(i = 1; i <= 100; i ++){
x = 1;
for(j = 1; j <= i; j ++)
x = (x * i) % 10;
V[i] = (V[i-1] + x) % 10;
}
return;
}
void CodeExpert(){
fin >> T;
for(i = 1; i <= T; i ++){
fin >> S + 1;
S[0] = '0';
N = strlen(S + 1);
nr = (S[N-1]-'0')*10+(S[N]-'0');
fout << V[nr] << "\n";
}
return;
}
int main(){
TestExpert();
CodeExpert();
return 0;
}