Cod sursa(job #1580998)
Utilizator | Data | 26 ianuarie 2016 13:47:04 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
int pow(int x)
{
int a=x,p=1;
while(a>0)
{
p*=x;
a--;
}
return p;
}
int cifra(int x)
{
if(x==1)
return 1;
else
return cifra(x-1)+pow(x)%10;
}
int main()
{
int x, T;
f>>T;
for(int i=0; i<T; i++)
{
f>>x;
g<<cifra(x)%10<<endl;
}
return 0;
}