Cod sursa(job #1527009)
| Utilizator | Data | 17 noiembrie 2015 19:28:41 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <fstream>
using namespace std;
double c (int x,int y)
{
if (y==1)
return 1;
else
return c(x,y-1)*x;
}
int u(int x)
{
if(x<10)
return x;
else
u(x%10);
}
int main()
{ fstream f1("cifra.in",ios::in);
fstream f2("cifra.out",ios::out);
long a[29000],i,n,k=0;
f1>>n;
for(i=1;i<=n;i++)
f1>>a[i];
for(i=1;i<=n;i++)
{k=k+c(a[i],a[i])*a[i];
f2<<u(k)<<endl;}
return 0;
}
