2 solutions

  • 0
    @ 2024-7-20 20:45:02

    开什么int,说了多少遍了,结果>=2^31的时候 开long long

    #include<bits/stdc++.h>
    using namespace std;
    long long a,b;
    int main(){
    	cin>>b;
    	long long k=1;
    	for(int i=1;i<=b;i++){
    		k*=2;
    	}
    	cout<<k;
    	return 0;
    }
    
    • 0
      @ 2024-7-20 20:38:40
      #include<bits/stdc++.h>
      #define ll long long
      
      using namespace std;
      
      int main(){
      	ll a, n = 1;
      	cin >> a;
      	for(int i = 0; i < a; i++){
      		n *= 2;
      	}
      	cout << n;
      	return 0;
      }
      
      • 1

      Information

      ID
      6878
      Time
      1000ms
      Memory
      128MiB
      Difficulty
      1
      Tags
      # Submissions
      11
      Accepted
      7
      Uploaded By