Cod sursa(job #718424)

Utilizator Tzappy90Mihalache Constantin Tzappy90 Data 20 martie 2012 19:43:39
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.37 kb
#include<fstream>
#include<cmath>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
long long n;
double x;
int sum(int x){
	int s=0;
	for(double j=1; j<=x; j++){
		s+=(int)pow(j,j)%10;
		s=s%10;
	}
	return s;
}

int main(){
	f>>n;
	for(int i=1; i<=n; i++){
		f>>x;
		if(x==1) g<<x<<'\n';
		else
			g<<sum(x)<<'\n';
	}
	return 0;
}