2022-08-18 16:07:09 +08:00

42 lines
776 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <iostream>
#include<cstdio>
#include<algorithm>
#include <cmath>
using namespace std;
const int mod=1000;
int qpow(int n,int k)
{
int res=1,now=n%mod;//要mod否则会太大10e6*10e6
while(k>0)
{
if(k&1==1)
{
res=res*now%mod;
}
k=k>>1;
now*=now;
now%=mod;
}
return res;//忘return
}
int main()
{
int t,t1=0;
int n,k;
int res1,res2;
double z;
double k10,cur;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&k);
k10=log10(n)*k;
cur=modf(k10,&z);
res1=floor(pow(10,cur)*100);
res2=qpow(n,k);
//%03d 001 000 补齐1前面的0
printf("Case %d: %d %03d\n",++t1,res1,res2);//没有int)导致没有输出
}
return 0;
}