Pagini recente » Cod sursa (job #737409) | Cod sursa (job #1859715) | Cod sursa (job #1400990) | Cod sursa (job #1485116) | Cod sursa (job #1741013)
#include <fstream>
#include <cstring>
using namespace std ;
ifstream f ("cifra.in") ;
ofstream g ("cifra.out") ;
char n[102] ;
int t , l , x , v[102] ;
int main ()
{
for ( int i = 1 ; i <= 99 ; ++i )
{
int result = 1 ;
for ( int j = 1 ; j <= i ; ++j )
result = ( result * i ) % 10 ;
v[i] = ( v[i-1] + result ) % 10 ;
}
f >> t ;
for ( ; t ; --t )
{
f.get () ;
f.get ( n , 101 ) ;
l = strlen ( n ) ;
if ( l > 1 )
x = ( n[l-2] - '0' ) * 10 + ( n[l-1] - '0' ) ;
else
x = n[l-1] - '0' ;
g << v[x] << "\n" ;
}
}