2 条题解

  • 1

    思路

    看注释。

    code

    #include<bits/stdc++.h>
    using namespace std;
    int a,b;
    int main(){
    	cin>>a>>b;
    	long long ans=pow(a,b);
    	if(ans<0||ans>1000000000){//如果溢出了或大于1e9
    		cout<<-1;
    	}else{
    		cout<<ans;
    	}
    	return 0;
    }
    
    • 0
      @ 2024-3-30 13:33:09

      //水题 #include <bits/stdc++.h> using namespace std; vector <int> v; int main() { int a,b; cin>>a>>b; long long int c; c=pow(a,b); if(pow(a,b)>1e9) { cout<<-1; } else{ cout<<c; } return 0; }

      • 1

      信息

      ID
      549
      时间
      1000ms
      内存
      256MiB
      难度
      8
      标签
      递交数
      78
      已通过
      11
      上传者