Cod sursa(job #1424010)
Utilizator | Data | 23 aprilie 2015 10:35:24 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.65 kb |
#include <fstream>
#include <cstring>
std::ifstream fin("cifra.in");
std::ofstream fout("cifra.out");
int a,b,c,d,v[]={0,1,4,7,6,5,6,3,6,9,0,1,6,3,6,5,6,7,4,8,9,0},i,k,j,n,t,x,ans;
char s[ 200 ];
int main()
{
fin>>n;
for( i = 1 ; i <= n ; ++i )
{
fin.get();
fin.get( s , 105 );
a = strlen( s );
if( a >= 2)
x = (int)s[ a - 2 ] * 10 + (int)s[ a - 1 ] - 96;
else
x = (int)s[ 0 ] - 48;
ans = 0;
for( j = 1 ; j <= x ; ++j )
{
ans = ( ans + v[ j % 20 ] ) % 10;
}
fout<<ans%10<<'\n';
}
return 0;
}