2 条题解

  • 1
    @ 2025-3-14 19:23:58

    快速幂

    #include<bits/stdc++.h>
    using namespace std;
    int a,b,ans;
    long long quickpow(int x,int n){
        if(n==0) return 1;
        if(n==1) return x;
        int num=quickpow(x,n/2);
        return (num*num)*((n&1)?x:1);
    }
    int main(){
        cin>>a>>b;
        ans=quickpow(a,b);
        cout<<ans;
        return 0;
    }
    
    • 0
      @ 2025-5-31 19:16:29
      a,n=map(int,input().split())
      print(a**n)
      

      简单方法,高级方法详见楼上ymh大佬

      • 1

      信息

      ID
      279
      时间
      1000ms
      内存
      128MiB
      难度
      9
      标签
      递交数
      10
      已通过
      10
      上传者