8.18下午
This commit is contained in:
parent
2d24ad3dac
commit
304d6ea774
41
8.16/J-LeadingandTrailing/main.cpp
Normal file
41
8.16/J-LeadingandTrailing/main.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user