Cod sursa(job #2778833)
Utilizator | Cristian Bota Avram CristiBota3 | Data | 2 octombrie 2021 11:31:45 |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp-32 | Status | done |
Runda | Arhiva de probleme | Marime | 0.7 kb |
#include <fstream>
using namespace std;
int ucif(int x)
{
if(x==1)
{
return 1;
}
int u1,u2,u3,u4;
u1=x%10;
u2=x*x%10;
u3=x*x*x%10;
u4=x*x*x*x%10;
if(x%4==0)
{
return u4+ucif(x-1);
}
else if(x%4==3)
{
return u3+ucif(x-1);
}
else if(x%4==2)
{
return u2+ucif(x-1);
}
else
{
return u1+ucif(x-1);
}
}
int main()
{
ifstream fin ("cifra.in");
ofstream fout ("cifra.out");
int t,x;
fin>>t;
for(int i=0;i<t;i++)
{
fin>>x;
fout<<ucif(x)%10<<endl;
}
fin.close();
fout.close();
return 0;
}