Pagini recente » Cod sursa (job #2638810) | Cod sursa (job #1984649) | Cod sursa (job #261516) | Cod sursa (job #517530) | Cod sursa (job #324173)
Cod sursa(job #324173)
#include <fstream>
#include <cmath>
#include <iostream>
#include <string.h>
using namespace std;
ifstream fin("cifra.in");
ofstream fout("cifra.out");
char ch, c, b;
int main()
{
long a[101] = {0};
long i, j, t, rez, x;
for ( i = 1; i < 101; i++)
{
rez = 1;
for(j = 1; j <= i;j++)
{
rez *= i;
rez = rez % 10;
}
a[i] = (rez + a[i-1]) %10;
}
fin >> t;
for ( i = 0 ; i < t; i++)
{
c = fin.get();
b = fin.get();
if ( c != '\n' && b != '\n')
while ( ch != '\n')
{
ch = fin.get();
if ( ch != '\n')
{
b = ch;
c = b;
}
}
if ( b != '\n')
x = (c - '0') * 10 + (b - '0');
if ( b == '\n')
x = c - '0';
fout << a[x] << '\n';
}
fin.close();
fout.close();
return 0;
}