Cod sursa(job #37230)

Utilizator RobytzzaIonescu Robert Marius Robytzza Data 24 martie 2007 18:19:53
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include<fstream.h>
//using namespace std;
int main(){
ifstream fin("cifra.in");
ofstream fout("cifra.out");
long N;
long x;
fin>>N;
long m;
const int a[4][10]={{0,1,6,1,6,5,6,1,6,1},{0,1,2,3,4,5,6,7,8,9},{0,1,4,9,6,5,6,9,4,1},{0,1,8,7,4,5,6,3,2,9}};
for (long i=0;i<N;i++){
     fin>>x;
     long long S=0;
     int e=0;
     for (long y=0;y<=x;y++){
	  if (e==4)
	      e=0;
	S+=a[e++][y%10]; }
fout<<S%10<<"\n";  }
fin.close();
fout.close();
return 0;
}