Cod sursa(job #729440)
| Utilizator | Data | 29 martie 2012 16:28:16 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.71 kb |
# include <fstream>
using namespace std ;
int main ( )
{
ifstream fin("cifra.in") ;
ofstream fout("cifra.out") ;
unsigned short T ;
int A[101] ,m , i , u , N , j , a ;
long long S ;
fin >> T ;
for ( m=1 ; m<=T ; m++ )
{
a=0;
fin >> N ;
for(j=1 ; j <= N ; j++)
{
S = 1 ;
for(i=1 ; i <= j ; i++)
{
S = S * j ;
S = S % 10 ;
}
a = S + a ;
a = a % 10 ;
}
fout << a << endl;
}
fin.close ( ) ;
fout.close ( ) ;
return 0 ;
}
