Cod sursa(job #2560479)
Utilizator | Data | 28 februarie 2020 01:52:25 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#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;
}