Cod sursa(job #2295517)
| Utilizator | Data | 3 decembrie 2018 18:32:44 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <fstream>
using namespace std;
ifstream fin("cifra.in");
ofstream fout("cifra.out");
typedef long long Int;
int calculate(int n){
int sum = 0;
for (int i = 1; i <= n; i++){
int prod = 1;
int cif = i%10;
int expo = i%4;
if(i==0)expo =4;
for (int j = 0; j < expo; j++)
prod = prod * cif % 10;
sum += (sum+prod) % 10;
}
return sum;
}
int main(){
int n,m;
fin >> n;
for (;n;n--){
fin >> m;
fout << calculate(m) << '\n';
}
return 0;
}
