Cod sursa(job #2339421)

Utilizator Hexor_ALXAlexandru Olteanu Hexor_ALX Data 8 februarie 2019 20:56:37
Problema Cifra Scor 0
Compilator cpp-32 Status done
Runda Arhiva de probleme Marime 1.04 kb
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll const mod=1000000007;
ll const md=998244353;
ll mypowr(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);
for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll mypow(ll a,ll b) {ll res=1;assert(b>=0);
for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}
ifstream in("cifra.in");
ofstream out("cifra.out");
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second



int main()
{   cout<<fixed<<setprecision(12);
    cin.tie(0);cout.tie(0);
    ios_base::sync_with_stdio(0);

    ll n;
    in>>n;
    while(n--){
        string s;in>>s;
        int u=s.size();
        ll x=0,res=0;
        for(int i=0;i<u;++i){
            ll y=int(s[i]-'0');
            x=x*10+y;
            res=res*10+x/9;
            x%=9;
            res%=10;
        }
        res=res*7;
        for(int i=1;i<=x;++i){
            res=res+mypow(i,i);
            res%=10;
        }
        out<<res<<'\n';
    }



    return 0;
}