1 solutions

  • 0
    @ 2024-7-20 13:13:28

    这都要看题解?

    #include<bits/stdc++.h>
    using namespace std;
    #define int long long
    const int e=1e9;
    int pow_pro(int a,int b){
    	int k=1;
    	for(int i=1;i<=b;i++){
    		k*=a;
    		if(k>e){
    			return -1;
    		}
    	}
    	return k;
    }
    signed main(){
    	int a,b;
    	cin>>a>>b;
    	cout<<pow_pro(a,b);
    	return 0;
    }
    
    • 1

    Information

    ID
    7834
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    1
    Tags
    # Submissions
    105
    Accepted
    34
    Uploaded By