lightoj1282

来源:互联网 发布:it治理与it管理的区别 编辑:程序博客网 时间:2024/06/17 01:27

题意是求一个数的前三位和后三位,特别注意后三位是0的情况,一定要%03lld矫正一下

#include<cstdio>#include<cmath>#define ll long longusing namespace std;ll n,k;ll mod_pow(ll x,ll w){    ll res=1;    while(w>0)    {        if(w&1)            res=res*x%1000;        x=x*x%1000;        w>>=1;    }    return res;}double ws(){    double w=k*log10(n);    double x=w-(ll)(w);    return x;}int solve(){    double d=ws();    ll temp=(ll)(pow(10,d)*100.0);    ll tmp=mod_pow(n,k);    printf("%lld %lld\n",temp,tmp);}int main(){    int T,cas=1;    scanf("%d",&T);    while(T--)    {        scanf("%lld %lld",&n,&k);        printf("Case %d: ",cas++);        solve();    }    return 0;}


0 0