Cod sursa(job #381105)

Utilizator iSeLastiSeLast iSeLast Data 8 ianuarie 2010 23:11:56
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.36 kb
#include<iostream>
#include<fstream>
using namespace std;
long int calc(long int n)
{
long int s,tr;
int x,j;
s=0;
for(x=1;x<=n;x++)
 {
 tr=1;
 for(j=1;j<=x;j++)
  tr*=x;
 s+=tr%10;
 }
return s;
}
int main()
{
ifstream f("cifra.in");
ofstream ff("cifra.out");
int i,t;
long int n;
f>>t;
for(i=1;i<=t;i++)
 {
 f>>n;
 ff<<calc(n)%10<<"\n";
 }
f.close();
ff.close();
}