Cod sursa(job #1155070)

Utilizator luci.agheLuci Aghergheloaei luci.aghe Data 26 martie 2014 17:12:31
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.36 kb
using namespace std;
#include<fstream>
#include<iostream>
#include<math.h>
int main()
{
	ifstream f("cifra.in");
	ofstream g("cifra.out");
	
	char a[255];
	int i , t, n,j;
	int s;
	f>>t;
	for(i=1;i<=t;i++)
	{
		s=0;
		f>>a;
		n=atoi(a);
		for(j=1;j<=n;j++)
			s=s+((int)(pow(j,j))%10);
		g<<(s%10)<<'\n';
	}
	f.close();
	g.close();
	return 0;
}