Cod sursa(job #2245710)

Utilizator ZydanCostica Dan Zydan Data 25 septembrie 2018 19:16:28
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
int pow(const int& pow)
{
	int res = 1;
	for (int i = 0; i < pow; i++)
	{
		res *= pow;
	}
	return res;
}

int calc(const int& m)
{
	if (m == 1) { return 1; }
	else
	{
		return calc(m - 1) + pow(m);
	}
}

int main()
{
	std::ifstream in("cifra.in");
	std::ofstream out("cifra.out");
	std::string s;
	std::getline(in, s);
	int n = std::stoi(s);


	int j;
	
	for(int i = 0 ;i<n ;i++)
	{
		std::getline(in,s);
		j = std::stoi(s);
		out << calc(j) %10 << '\n';
		
	}


}