• Leading and Trailing 题解(a^b的前三位)


    题目链接

    题目思路

    对于这种很大数还是要想到用对数

    (n^k) =$10x imes10y $,其中(10^x) 的值等于位数,而(10^y)(这是一个大于等于1小于10的浮点数)决定了位数上的值。
    我们把(10^y)求出来

    代码

    #include<bits/stdc++.h>
    #define fi first
    #define se second
    #define debug cout<<"I AM HERE"<<endl;
    using namespace std;
    typedef long long ll;
    typedef pair<int,int> pii;
    const int maxn=2e6+5,inf=0x3f3f3f3f,mod=1000;
    const double eps=1e-6;
    ll a,b;
    int tot;
    ll qpow(ll a,ll b){
        ll ans=1,base=a;
        while(b){
            if(b&1) ans=ans*base%mod;
            base=base*base%mod;
            b=b>>1;
        }
        return ans;
    }
    signed main(){
        int _;scanf("%d",&_);
        while(_--){
            scanf("%lld %lld",&a,&b);
            double xs=b*log10(a)-(ll)(b*log10(a));
            ll ans1=(ll)(pow(10,xs)*100);
            ll ans2=qpow(a,b);
            printf("Case %d: %03lld %03lld
    ",++tot,ans1,ans2);
        }
        return 0;
    }
    
    
    不摆烂了,写题
  • 相关阅读:
    实验三
    第四次实验
    作业
    第二次实验
    <转>JVM调优
    SQL Server的聚集索引和非聚集索引
    去除DataTable里面重复的数据
    sql server 与 Excel 导入导出
    C#学习笔记 委托和事件
    好多特效
  • 原文地址:https://www.cnblogs.com/hunxuewangzi/p/15127455.html
Copyright © 2020-2023  润新知