Pagini recente » Cod sursa (job #594537) | Cod sursa (job #2276231) | Cod sursa (job #1486728) | Cod sursa (job #2882837) | Cod sursa (job #222603)
Cod sursa(job #222603)
#include <stdio.h>
#include <math.h>
int t;
long n;
int cifra(long x)
{int c=x%10;
switch (c) {
case 0: return 0;
case 1: return 1;
case 2: return (int)pow(2,x)%10;
case 3: return (int)pow(3,x)%10;
case 4: return (int)pow(4,x)%10;
case 5: return 5;
case 6: return 6;
case 7: return (int)pow(7,x)%10;
case 8: return (int)pow(8,x)%10;
case 9: return (int)pow(9,x)%10;
}}
int main()
{
freopen("cifra.in", "r", stdin);
freopen("cifra.out", "w", stdout);
scanf("%d", &t);
for(int i=0;i<t;i++) {scanf("%ld", &n);
int s=0;
for(int j=1;j<=n;j++) s+=cifra(j);
s=s%10;
printf("%d\n", s);
}
fclose(stdin);
fclose(stdout);
}