Cod sursa(job #1438263)
Utilizator | Data | 19 mai 2015 15:20:21 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
int table[] = {
0, 0, 0, 0, 1, 1, 1, 1, 6, 2, 4, 8, 1, 3, 9, 7, 6, 4, 6, 4,
5, 5, 5, 5, 6, 6, 6, 6, 1, 7, 9, 3, 6, 8, 4, 2, 1, 9, 1, 9
};
int unit_digit(int n, int a)
{
return table[((n%10)<<2)+(a&3)];
}
int main()
{
int n;
int s=0,c;
f>>n;
for(int i=1;i<=n;i++)
{
f>>c;
s=(s+unit_digit(c,i))%10;
g<<s<<endl;
}
return 0;
}