Cod sursa(job #1424142)

Utilizator DysKodeTurturica Razvan DysKode Data 23 aprilie 2015 16:54:19
Problema Cifra Scor 100
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,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 ] - 48 ) * 10 + (int)s[ a - 1 ] - 48;
        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;
}