Cod sursa(job #1453421)

Utilizator Costin.StanciuStanciu Costin Costin.Stanciu Data 23 iunie 2015 14:52:43
Problema Cifra Scor 0
Compilator c Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int j, i, n, c, x, t, k;

    freopen("cifra.in", "r", stdin);
    freopen("cifra.out", "w", stdout);

    scanf("%d", &t);

    for (k = 1; k <= t; k++)
    {
        scanf("%d", &n);
        c = 0;

        for (i = 1; i <= n; i++)
        {
            x = i;
            j = i - 1;
            while (j > 0)
            {
                x = x * i;
                j--;
            }
            c = c + x % 10;
        }
        c = c % 10;
        printf ("%d\n", c);
    }
    return 0;
}