Cod sursa(job #3329130)
| Utilizator | Data | 11 decembrie 2025 20:41:10 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 3.83 kb |
#include <iostream>
ifstream fin("cifra.in");
ofstream fout("cifra.out");
using namespace std;
int putere(int n, unsigned int p)
{
int rezultat=1;
while(p>0)
{
if(p%2==1)
{
rezultat=rezultat*n;
}
n=n*n;
p=p/2;
}
return rezultat;
}
int main()
{
int T,N,S,r,i,cif,cif2;
fin>>T;
while(T!=0)
{
fin>>N;
S=0;
S=((N/20)*4)%10;
r=N%20;
if(r!=0)
{
for(int j=1;j<=r;j++)
{
i=j;
cif=i%10;
if(cif==0)
{
}
else
{
if(cif==1)
{
S=S+1;
}
else
{
if(cif==2)
{
cif2=i%4;
if(cif2==0)
{
cif2=4;
}
S=S+putere(cif,cif2)%10;
}
else
{
if(cif==3)
{
cif2=i%4;
if(cif2==0)
{
cif2=4;
}
S=S+putere(cif,cif2)%10;
}
else
{
if(cif==4)
{
cif2=i%2;
if(cif2==0)
{
cif2=4;
}
S=S+putere(cif,cif2)%10;
}
else
{
if(cif==5)
{
S=S+5;
}
else
{
if(cif==6)
{
S=S+6;
}
else
{
if(cif==7)
{
cif2=i%4;
if(cif2==0)
{
cif2=4;
}
S=S+putere(cif,cif2)%10;
}
else
{
if(cif==8)
{
cif2=i%4;
if(cif2==0)
{
cif2=4;
}
S=S+putere(cif,cif2)%10;
}
else
{
if(cif==9)
{
cif2=i%2;
if(cif2==0)
{
cif2=2;
}
S=S+putere(cif,cif2)%10;
}
}
}
}
}
}
}
}
}
}
}
}
T--;
fout<<S%10<<endl;
}
return 0;
}
