Cod sursa(job #509049)
Utilizator | Uncu Florin florin.uncu | Data | 10 decembrie 2010 10:30:51 |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
//#include "stdafx.h"
#include <fstream>
#include <stdlib.h>
#include <iostream>
using namespace std;
ifstream f_in("cifra.in");
ofstream f_out("cifra.out");
unsigned long c(int x)
{
unsigned long p = 1;
for (int i=1;i<=x;i++) p *= x;
return p;
}
int main()
{
int T,i,j;
char X[201];
long x;
unsigned long s;
f_in>>T;
for (i=1;i<=T;i++)
{
f_in>>X;
x = atol(X);
s = 0;
for (j=1;j<=x;j++) s += c(j);
f_out<<s%10<<endl;
}
return 0;
}