Cod sursa(job #2474076)
| Utilizator | Data | 14 octombrie 2019 18:15:06 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 1.05 kb |
#include <fstream>
#include <cstring>
#include <cmath>
using namespace std;
ifstream in("cifra.in");
ofstream out("cifra.out");
char s[105];
int main()
{
long long t,i,n,ucif=0,x,y,xy,beta,j,power;
in>>t;
for(i=1; i<=t; i++)
{
ucif=0;
in>>(s+1);
n=strlen(s+1);
if(n>=2)
{
x=s[n]-'0';
y=s[n-1]-'0';
xy=x*10+y;
xy%=20;
for(j=1;j<=xy;j++)
{
if(j%4==0)
beta=4;
else
beta=j%4;
power=pow(j,beta);
ucif=(ucif+power%10)%10;
}
}
else
if(n==1)
{
x=s[n]-'0';
for(j=1;j<=x;j++)
{
if(j%4==0)
beta=4;
else
beta=j%4;
power=pow(j,beta);
ucif=(ucif+power%10)%10;
}
}
out<<ucif<<'\n';
}
return 0;
}
