3 条题解

  • 1
    @ 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;
    }
    
    • 1
      @ 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; }

      • 0
        @ 2025-7-15 22:34:18
        using namespace std;
        int main()
        {
            long long  a,b;
            cin>>a>>b;
            if(pow(a,b)<=1e9)
            {
                cout<<(int)pow(a,b);
            }
            else
            {
                cout<<-1;
            }
        }
        //怕自己也成了小文,所以开了long long 
        
        
        • @ 2025-7-15 23:23:30

          第一眼看这题,完了,要写高精度。再一看,没事了

      • 1

      信息

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