2 条题解

  • 1
    @ 2025-11-18 0:00:53
    #include <bits/stdc++.h>
    using namespace std;
    int a,b,c=1;
    int main(){
        cin >> a >> b;
        for (long long i=1; i<=b; i++){
        	c*=a;
        	if (c>1e9||c<=0){
        		cout << -1;
        		return 0;
    		}
    	}
        cout << c;
    	return 0; 
    }
    //彭子洋 原创  ^-^  // 
    
    • 0
      @ 2024-11-21 20:49:57
      #include <bits/stdc++.h>
      #define LL long long
      
      using namespace std;
      int a , b , c = 1;
      const int N = 1e9;
      const int INF = 0x3f3f3f3f;
      int main()
      {
      	    cin >> a >> b;
      	    for (LL i = 1; i <= b; i++)
      	    {
      	    	c *= a;
      	    	if (c > N || c <= 0)
      	    	{
      	    		cout << -1;
      	    		return 0;
      			}
      
      		}
              cout << c;
      		return 0; 
      }
      
      • 1

      信息

      ID
      2916
      时间
      1000ms
      内存
      256MiB
      难度
      8
      标签
      递交数
      525
      已通过
      125
      上传者