Cod sursa(job #1133821)
| Utilizator | Data | 5 martie 2014 17:51:12 | |
|---|---|---|---|
| Problema | Cifra | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.69 kb |
#include <fstream>
#include <cstring>
using namespace std;
int main()
{
ifstream f("cifra.in");
ofstream g("cifra.out");
int n ,x, j , k , i,S=0,cnt;
char a[105];
f >> n;
f.getline(a,10);
for (i=1;i<=n;i++)
{
f.getline(a,105);
x=strlen(a);
if(x==1)
x = a[0]-'0';
else
x = (a[x-2] - '0') * 10 + a[x-1] - '0';
for (j=1;j<=x;j++)
{
cnt=1;
if (j%4==0)
cnt=j*j*j*j;
else
for (k=1;k<=j%4;k++)
cnt=cnt*j;
S=S+cnt%10;
}
S=S%10;
g << S << '\n';
S=0;
}
}
