Cod sursa(job #2886075)
Utilizator | Data | 6 aprilie 2022 22:18:54 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.4 kb |
#include <cmath>
#include <fstream>
#include <iostream>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
int calcLast(int x) {
if (x == 0) return 0;
return pow(x, x) + calcLast(x - 1);
}
int main() {
int n, x;
f >> n;
for (int i = 1; i <= n; i++) {
f >> x;
g << calcLast(x) % 10 << endl;
}
f.close();
g.close();
}