3 条题解

  • 2
    @ 2023-8-9 15:35:52
    #include<bits/stdc++.h>
    #define int long long
    using namespace std;
    int a,b,c;
    signed main(){
    	cin>>a>>b;
    	c = a;
    	for(int i = 2;i<=b;i++){
    		a = a * c;
    		if(a>1e9){
    			cout<<-1;
    			return 0;
    		}
    	}
    	cout<<a;
    	return 0;
    }
    
    • 1
      @ 2023-9-30 11:06:14
      
      
      #include<iostream>
      #include<cstdio>
      #include<cmath>
      #include<algorithm>
      using namespace std;
      long long a,b;
      long long c;
      int main(){
      	//freopen("pow.in","r",stdin);
      	//freopen("pow.out","w",stdout);
      	scanf("%lld %lld",&a,&b);
      	c = 1;
      	for(int i=1;i<=b;i++){
      		c*=a;
      		if(c>1e9){
      			printf("%s","-1");
      			return 0;
      		}		
      	} 
      	printf("%lld",c);
      	//fclose(stdin);
      	//fclose(stdout);
      	return 0;
      }
      
      • 0
        @ 2023-10-22 13:04:51
        #include <bits/stdc++.h>
        using namespace std;
        int main()
        {
            int max = pow(10,9);
            long long sum = 1;
            long long a,b;
            cin>>a>>b;
            for (int i = 1;i <= b;i++)
            {
                sum *= a;
                if (sum > max)
                {
                    cout<<-1;
                    return 0;
                }
            }
            if (sum == 0)
            {
                cout<<-1;
                return 0;
            }
            cout<<sum;
            return 0;
        }
        
        • 1

        信息

        ID
        7632
        时间
        1000ms
        内存
        128MiB
        难度
        1
        标签
        递交数
        57
        已通过
        20
        上传者