Cod sursa(job #1608043)
Utilizator | Andrei Cotor Andrei_Cotor | Data | 21 februarie 2016 19:44:47 |
---|---|---|---|
Problema | Cifra | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#include<fstream>
#include<string.h>
using namespace std;
ifstream fi("cifra.in");
ofstream fo("cifra.out");
int A[]={1,4,7,6,5,6,3,6,9,0,1,6,3,6,5,6,7,4,9,0};
int V[]={0,4,8,2,6};
char S[101];
char *p;
int n,i,rez,x,j;
int main()
{
fi>>n;
for(i=1; i<=n; i++)
{
rez=0;
fi>>S;
if(strlen(S)<=2)
p=S;
else
p=S+strlen(S)-2;
x=atoi(p);
for(j=0; j<x%20; j++)
rez=rez+A[j];
fo<<(V[x/20]+rez)%10<<"\n";
}
fi.close();
fo.close();
return 0;
}