Cod sursa(job #2309161)

Utilizator valentin35Valentin Popescu valentin35 Data 28 decembrie 2018 15:28:44
Problema Cifra Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.37 kb
#include <fstream>
#include <iostream>
#include <math.h>

using namespace std;

ifstream in("cifre.in.txt");
ofstream out("cifre.out");

int main()
{
	int n, t, s;
	in >> t;

	for (int i = 1; i <= t; i++)
	{
		in >> n;
		s = 0;

		for (int j = 1; j <= n; j++)
		{
			s += (int)pow(j, j) % 10;
		}

		out << s % 10 << "\n";
	}

	//cin.get();
	return 0;
}