Pagini recente » Clasamentul arhivei Infoarena Monthly | clasament-arhiva-monthly | Cod sursa (job #1095281) | Cod sursa (job #211605) | Cod sursa (job #2560479)
#include <fstream>
using namespace std;
int pow(int x, int y){
int rez = 1;
for(int i = 1; i<=y; i++){
rez = rez * x;
}
return rez;
}
int main(){
int T, nr, sum = 0;
ifstream fileIn("cifra.in")
ofstream fileOut("cifra.out");
if(fileIn.is_open()){
fileIn>>T;
for(int i = 0; i<T; i++){
fileIn>>nr;
for(int k = 1; k<=nr; k++){
sum = sum + pow(k,k);
}
fileOut<<sum%10<<endl;
}
}
fileIn.close();
fileOut.close();
return 0;
}