Cod sursa(job #1811089)

Utilizator shantih1Alex S Hill shantih1 Data 20 noiembrie 2016 20:47:04
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;

int i, j, n, nr, k;
long long y, z;
unsigned long long x, s;

char a[100];

int main() {
    
    ifstream fin("cifra.in");
    ofstream fout("cifra.out");
    fin >> n;
    
    for (i = 1; i <= n; i++)
    {
        fin >> a[i];
        a[i] = a[i] - '0';
        for (j = 1; j <= a[i]; j++)
        {
            z = 1;
            for (k = 1; k <= j; k++)    z = z * j%10;
            s = s + z%10;
        }

        fout << s%10  << "\n";
        s = 0;
    }
    
    return 0;
}