Pagini recente » Cod sursa (job #5416) | Cod sursa (job #242790)
Cod sursa(job #242790)
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream f;
ofstream g;
f.open("cifra.in");
g.open("cifra.out");
int t;
int n;
int i;
int j;
int exponent=0;
int suma=0;
int putere=1;
int k;
f>>t;
for(i=1; i<=t; i++) {
f>>n;
suma = 0;
putere=1;
for(j=1; j<=n; j++) {
exponent=j;
putere=1;
for(k=1; k<=exponent; k++) {
putere=putere*j;
}
suma=suma+putere;
}
if(suma>=10) {
suma=suma%10;
}
g<<suma<<endl;
}
f.close();
g.close();
return 0;
}