Cod sursa(job #1194098)
| Utilizator | Data | 2 iunie 2014 20:12:52 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.68 kb |
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
int n, k, l ,a[101];
char c[100];
int main()
{
f >> n;
for ( int i = 1; i < 100; i++)
{
k = i;
for ( int j = 1; j < i ; j++ )
{
k *= i;
k %= 10;
}
a[i] = ( k + a[i-1] ) % 10;
}
while ( n > 0 )
{
f >> c;
l = sizeof(c);
if ( l >= 2 )
g << a[(c[l - 2] - '0' ) * 10 + (c[l-1] - '0')] << '\n';
else g << a[c[l - 1] - '0'] << '\n';
n--;
}
g.close();
f.close();
return 0;
}
