#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll lastDigit(ll n, ll k)
{
if(k == 0)
return 1;
ll x = lastDigit(n, k/2);
if(k%2 == 1)
return (x*x*n)%1000;
else
return (x*x)%1000;
return x;
}
int main()
{
ll t, i, j, n, k;
while(cin >> t)
{
for(i=1;i<=t;i++)
{
cin >> n >> k;
ll r = lastDigit(n, k);
double a = k * log10(n);
ll ans = pow(10, a - (int)a)*100.0;
printf("%lld...%03lld\n", ans, r);
}
}
return 0;
}
#define ll long long int
using namespace std;
ll lastDigit(ll n, ll k)
{
if(k == 0)
return 1;
ll x = lastDigit(n, k/2);
if(k%2 == 1)
return (x*x*n)%1000;
else
return (x*x)%1000;
return x;
}
int main()
{
ll t, i, j, n, k;
while(cin >> t)
{
for(i=1;i<=t;i++)
{
cin >> n >> k;
ll r = lastDigit(n, k);
double a = k * log10(n);
ll ans = pow(10, a - (int)a)*100.0;
printf("%lld...%03lld\n", ans, r);
}
}
return 0;
}
Comments
Post a Comment