Pagini recente » Cod sursa (job #1079382) | Cod sursa (job #2965761) | Cod sursa (job #99295) | Cod sursa (job #1294719) | Cod sursa (job #1208109)
#include<cstdio>
#include<stdlib.h>
#include<math.h>
#include<string>
#include<fstream>
#include<iostream>
using namespace std;
int main()
{
ifstream si;
si.open("cifra.in");
ofstream so;
so.open("cifra.out");
int t;
si>>t;
int i;
int n,m,uc,j,z;
string v;
char a;
for(i=0;i<t;++i)
{
m=0;
si>>v;
si.ignore();
if(v.length()==1)
{
m=v[0]-48;
n=0;
}
else
{
m=v[v.length()-1]-48;
n=v[v.length()-2]-48;
}
if(m==0)
if(n!=0)
uc=((n-1)*7)%10;
else
uc=0;
else
{
uc=(n*7)%10;
for(j=1;j<=m;++j)
{
if((j+n*10)%4==0)
uc=uc+pow(j,4);
else
uc=uc+pow(j,(j+n*10)%4);
uc=uc%10;
}
}
so<<uc<<endl;
}
}