Cod sursa(job #703086)
| Utilizator | Data | 2 martie 2012 10:51:40 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 1.55 kb |
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
int main()
{
fstream f ("cifra.in", ios::in), g("cifra.out", ios::out);
long long c,t,i,S=0,j;
int cifra;
f>>t;
for(i=0;i<t;i++)
{
f>>c;
for(j=1;j<=c;j++)
{
cifra=j%10;
switch(cifra)
{
case 1: S+=1; break;
case 2: if(j%4==1) S+=2;
else if(j%4==2) S+=4;
else if(j%4==3) S+=8;
else S+=6;
break;
case 3: if(j%4==1) S+=3;
else if(j%4==2) S+=9;
else if(j%4==3) S+=7;
else S+=1;
break;
case 4: if(j%2==1) S+=4;
else S+=6;
case 5: S+=5;
case 6: S+=6;
case 7: if(j%4==1) S+=7;
else if(j%4==2) S+=9;
else if(j%4==3) S+=3;
else S+=1;
break;
case 8: if(j%4==1) S+=8;
else if(j%4==2) S+=4;
else if(j%4==3) S+=2;
else S+=6;
break;
case 9: if(j%2==1) S+=9;
else S+=1;
case 0: break;
}
}
g<<(S%10)<<endl;
S=0;
}
return 0;
}
