Cod sursa(job #324067)
| Utilizator | Data | 14 iunie 2009 16:02:03 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("cifra.in");
ofstream fout("cifra.out");
int main()
{
int a[101] = {0};
int i, j, t, rez, x;
for ( i = 1; i < 101; i++)
{
rez = 1;
for(j = 1; j <= i;j++)
rez *= i;
a[i] = rez % 10 + a[i-1] ;
}
fin >> t;
for ( i = 0 ; i < t; i++)
{
fin >> x;
if ( x > 100)
x = x % 100;
fout << a[x] % 10 << '\n';
}
fin.close();
fout.close();
return 0;
}
