2 条题解

  • 0
    @ 2025-4-21 18:08:57
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        long long a,b;
        cin>>a>>b;
        long long n=pow(a,b);
        if(pow(a,b)>pow(10,9)){
            cout<<"-1";
            return 0;
        }
        cout<<n;
    }
    
    • 0
      @ 2025-1-21 23:05:24

      #include <bits/stdc++.h> using namespace std; int a,b; int main(){ cin>>a>>b; if(a==1){ cout<<"1"; return 0; } long long ans=1; for(int i=1;i<=b;i++){ ans=a*ans; if(ans>1000000000){ cout<<"-1"; return 0; } } printf("%lld",ans); return 0; }

      • 1

      信息

      ID
      154
      时间
      1000ms
      内存
      256MiB
      难度
      8
      标签
      递交数
      71
      已通过
      9
      上传者