Cod sursa(job #2228640)
Utilizator | Data | 4 august 2018 15:06:34 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#include <fstream>
#include<iostream>
#include<cmath>
using namespace std;
ifstream f("cifra.in");
ofstream o("cifra.out");
int n,t,s;
int suma(int k)
{s=0;
for(int i=1; i<=k; i++)
{
s+=pow(i,i);
}
if(s>=10)
return s%10;
return s;
}
int main()
{f>>t;
while(f>>n)
o<<suma(n)<<endl;
return 0;
}