Cod sursa(job #2094510)

Utilizator DimaTCDima Trubca DimaTC Data 26 decembrie 2017 00:16:11
Problema Cifra Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include<bits/stdc++.h>

using namespace std;

int n,t;
string s;
long long x;
long long s1;

int main() {
	ifstream cin("cifra.in");
	ofstream cout("cifra.out");
	cin>>t;
	while (t--) {
	
	cin>>s;
	
	if (s.size()>=2) n = (s[s.size()-2]-'0')*10 + s[s.size()-1]-'0';	
	else n=s[s.size()-1]-'0';
	x=1;
	s1=0;
	for (int i=1; i<=n; i++) {
		x=1;
		for (int j=1; j<=i; j++) {
			x=(x*i)%10;
		}
		s1=(s1+x)%10;
	}
	
	
	cout<<s1%10<<'\n';
	}
}