题目:click
题意:求n的k次幂的前三位后三位。
后三位直接取模,千万注意。。。可能有003这种情况保留三位输出。
前三位
取对数,
,可得要知道x.y*100,要知道结果的len(具体位数减1),可推出答案。
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<istream>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f
#define MAX_len 200005*4
using namespace std;
typedef long long ll;
typedef pair<int,int> PP;
ll qpow(ll a,ll n,ll p)
{
ll res=1;
while(n)
{
if(n&1)
res=(res*a)%p;
n>>=1;
a=((a%p)*(a%p))%p;
}
return res;
}
int main()
{
cout<<log10(100)<<endl;
int T;
scanf("%d",&T);
int cases=1;
while(T--)
{
ll n,k,i,j;
scanf("%lld %lld",&n,&k);
ll t1=qpow(n,k,1000);
ll len=k*log10(n);
double temp=k*1.0*log10(n)-len*1.0;
double tmp=pow((double)10,temp);
ll ans=tmp*100;
printf("Case %d: %lld %03lld\n",cases++,ans,t1);
}
return 0;
}