Cod sursa(job #1969831)

Utilizator mihai2003LLL LLL mihai2003 Data 18 aprilie 2017 17:51:39
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <bits/stdc++.h>
using namespace std;
ifstream in("cifra.in");
ofstream out("cifra.out");
char v[1001];
short sult[1001];
inline short mp(short nr)
{
    short uc=1;
    for(short i=1;i<=nr;i++)uc=uc*(nr%10),uc%=10;
    return uc;
}
inline void generare()
{
    for(int i=1; i<=100; i++)
         sult[i]=(sult[i-1]+mp(i))%10;
}
int main()
{
   // ios_base::sync_with_stdio(false);
    short n,le;
    int m;
    in>>n>>ws;
    generare();
    for(short i=1; i<=n; i++)
    {
        in>>v>>ws;
        //out<<v<<endl;
        le=strlen(v);
        m=(le>=2)?v[le-2]-'0':0;
        m+=v[le-1]-'0';
        out<<sult[m]<<'\n';
    }
    return 0;
}