Cod sursa(job #1692113)
| Utilizator | Data | 20 aprilie 2016 10:07:46 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <fstream>
#include <cstring>
using namespace std;
ifstream in("cifra.in");
ofstream out("cifra.out");
const int nmax=100;
int v[nmax+5];
int main()
{
int i,j,u,t,p,n,e;
for(i=1; i<=nmax; i++)
{
u=i%10;
e=i%4;
if(e==0)
e=4;
p=1;
for(j=1; j<=e; j++)
p=p*u;
p=p%10;
v[i]=(v[i-1]+p)%10;
}
char s[105];
in>>t;
in.get();
for(i=1; i<=t; i++)
{
in.getline(s,105);
n=strlen(s);
out<<v[i]<<"\n";
}
return 0;
}
